请尝试使用两种方式模仿画出下面的图表(重点是柱状图上的标签),本文学习的text方法和matplotlib自带的柱状图标签方法bar_label
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
Names = ('Jim', 'Slim', 'Harry', 'Dick', 'Tom')
np_array = 8 + np.random.rand(len(Names))
error = np.random.rand(len(Names)).round(2)
plt.barh(Names, np_array, xerr=error)
fig.suptitle('How fast do you wang to go today', fontsize=14) # 标题
ax.set_xlabel('Performance')
ax.xaxis.set_ticks(np.arange(0, 20, 2))
for i in range(0, 5):
ax.text(np_array[i] + error[i] + 1, Names[i], '±' + str(error[i]), fontsize=10, horizontalalignment='center',
color='blue')
plt.show()