1. # coding=utf-8
    2. from matplotlib import pyplot as plt
    3. from matplotlib import font_manager
    4. interval = [0,5,10,15,20,25,30,35,40,45,60,90]
    5. width = [5,5,5,5,5,5,5,5,5,15,30,60]
    6. quantity = [836,2737,3723,3926,3596,1438,3273,642,824,613,215,47]
    7. print(len(interval),len(width),len(quantity))
    8. #设置图形大小
    9. plt.figure(figsize=(20,8),dpi=80)
    10. plt.bar(range(12),quantity,width=1)
    11. #设置x轴的刻度
    12. _x = [i-0.5 for i in range(13)]
    13. _xtick_labels = interval+[150]
    14. plt.xticks(_x,_xtick_labels)
    15. plt.grid(alpha=0.4)
    16. plt.show()
    1. # coding=utf-8
    2. from matplotlib import pyplot as plt
    3. from matplotlib import font_manager
    4. interval = [0,5,10,15,20,25,30,35,40,45,60,90]
    5. width = [5,5,5,5,5,5,5,5,5,15,30,60]
    6. quantity = [836,2737,3723,3926,3596,1438,3273,642,824,613,215,47]
    7. print(len(interval),len(width),len(quantity))
    8. #设置图形大小
    9. plt.figure(figsize=(20,8),dpi=80)
    10. plt.bar(interval,quantity,width=width)
    11. #设置x轴的刻度
    12. temp_d = [5]+ width[:-1]
    13. _x = [i-temp_d[interval.index(i)]*0.5 for i in interval]
    14. clear
    15. plt.xticks(_x,interval)
    16. plt.grid(alpha=0.4)
    17. plt.show()