y = [450, 500, 200, 1000]
# 绘图
plt.bar(x=x, height=y, label='书库大全', color='steelblue', alpha=0.8)
# 在柱状图上显示具体数值...color='steelblue', alpha=0.8)
plt.bar(x=x, height=y2, label='java', color='indianred', alpha=0.8)
# 在柱状图上显示具体数值...plt.xlabel("年份")
plt.ylabel("销量")
# 显示图例
plt.legend()
plt.savefig("a.jpg")
plt.show()
图形效果展示:
绘制柱状图的条柱并列显示...np.arange(len(x)) + bar_width, height=y2, label='java', color='indianred', alpha=0.8, width=bar_width)
# 在柱状图上显示具体数值...y = [450, 500, 200, 1000]
# 绘图
plt.bar(x=x, height=y, label='书库大全', color='steelblue', alpha=0.8)
# 在柱状图上显示具体数值