python可視化---堆積柱狀圖

import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams["font.sans-serif"] = ["SimHei"] mpl.rcParams["axes.unicode_minus"] = False x = [1, 2, 3, 4, 5] y = [6, 10, 4, 5, 1] y1 = [2, 6, 3, 8, 5] plt.bar(x, y, align="center", color="#66c2a5", tick_label=["A", "B", "C", "D", "E"], label="班級A") plt.bar(x, y1, align="center", bottom=y, color="#8da0cb", label="班級B") plt.xlabel("測試難度") plt.ylabel("試卷份數") plt.legend() plt.show()

相關文章
相關標籤/搜索