import matplotlib.pyplot as plt
if __name__ == '__main__':
x = ["1234", "2345", "5678", "6789", "7890"]
y = [1, 2, 3, 4, 5]
plt.bar(x, y, width=0.35)
plt.xticks(x, x, rotation=30) # 这里是调节横坐标的倾斜度,rotation是度数
# 显示柱坐标上边的数字
for a, b in zip(x, y):
plt.text(a, b + 0.05, '%.0f' % b, ha='center', va='bottom', fontsize=17) # fontsize表示柱坐标上显示字体的大小
plt.show()
结果如下: