import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False
x = np.arange(5)
y = [60, 10, 40, 50, 10]
y1 = [20, 60, 30, 80, 50]
bar_width = 0.35
tick_label = ["A", "B", "C", "D", "E"]
plt.bar(x, y, bar_width, align="center", color="red", label="项目A", alpha=0.5)
plt.bar(x+bar_width, y1, bar_width, color="blue", align="center", label="项目B", alpha=0.5)
plt.xlabel("种类")
plt.ylabel("数量")
plt.xticks(x+bar_width/2, tick_label)
plt.legend()
plt.show()
python pyplot绘制并行柱状图,x轴数值显示在两个柱状图的中心
原文作者:AI浩
原文地址: https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/114057980
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://blog.csdn.net/hhhhhhhhhhwwwwwwwwww/article/details/114057980
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。