1. # coding=utf-8
    2. from matplotlib import pyplot as plt
    3. from matplotlib import font_manager
    4. my_font = font_manager.FontProperties(fname="/System/Library/Fonts/Hiragino Sans GB.ttc")
    5. a = ["猩球崛起3:终极之战","敦刻尔克","蜘蛛侠:英雄归来","战狼2"]
    6. b_16 = [15746,312,4497,319]
    7. b_15 = [12357,156,2045,168]
    8. b_14 = [2358,399,2358,362]
    9. bar_width = 0.2
    10. x_14 = list(range(len(a)))
    11. x_15 = [i+bar_width for i in x_14]
    12. x_16 = [i+bar_width*2 for i in x_14]
    13. #设置图形大小
    14. plt.figure(figsize=(20,8),dpi=80)
    15. plt.bar(range(len(a)),b_14,width=bar_width,label="9月14日")
    16. plt.bar(x_15,b_15,width=bar_width,label="9月15日")
    17. plt.bar(x_16,b_16,width=bar_width,label="9月16日")
    18. #设置图例
    19. plt.legend(prop=my_font)
    20. #设置x轴的刻度
    21. plt.xticks(x_15,a,fontproperties=my_font)
    22. plt.show()