这取决于你想要展示什么,
按尺寸排序的所有酒吧
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
X = np.array([19, 35, 29, 10, 5, 9, 45, 72, 3, 18])
Y = np.array([14336, 6812, 4265, 3857, 2960, 1986, 1730, 1233, 1128, 841])
ax = sns.barplot(X,Y, order=X)
for p, q in zip(ax.patches, Y):
ax.text(p.get_x()+p.get_width()/2.,
p.get_height()*(1.01),
"{}".format(q),
ha = 'center' )
plt.show()
按x值排序的所有条形图
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
X = np.array([19, 35, 29, 10, 5, 9, 45, 72, 3, 18])
Y = np.array([14336, 6812, 4265, 3857, 2960, 1986, 1730, 1233, 1128, 841])
ax = sns.barplot(X,Y)
for p, q in zip(ax.patches, Y[np.argsort(X)]):
ax.text(p.get_x()+p.get_width()/2.,
p.get_height()*(1.01),
"{}".format(q),
ha = 'center' )
plt.show()