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/PingFang.ttc")
    5. y = [1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
    6. x = range(11,31)
    7. #设置图形大小
    8. plt.figure(figsize=(20,8),dpi=80)
    9. plt.plot(x,y)
    10. #设置x轴刻度
    11. _xtick_labels = ["{}岁".format(i) for i in x]
    12. plt.xticks(x,_xtick_labels,fontproperties=my_font)
    13. plt.yticks(range(0,9))
    14. #绘制网格
    15. plt.grid(alpha=0.1)
    16. #展示
    17. plt.show()