zoukankan      html  css  js  c++  java
  • python subplot

    # owner:@aviviguixiang
    # createtime:2019/7/22
    # 任务:芒市20190326—20190328、20190330—20190401气象场、监测数据逐时折线

    import pandas as pd
    import matplotlib.pyplot as plt
    import matplotlib.font_manager as fm
    zhfont1 = fm.FontProperties(fname=r'D:pycharm_project190325 aihexiandataSIMKAI.TTF')


    def draw(data,a,b,p1,p2,p3,p4,p5,p6):
    fig,(ax00, ax10, ax20, ax30) = plt.subplots(4, 1, sharex=True,figsize=(10, 11))
    # fig, ax = plt.subplots(4, 1, figsize=(10, 11))
    ax00 .plot(data.loc[a:b,p1].values,'k-',linewidth=2)
    ax00.set_ylabel(r'温度(℃)',fontproperties=zhfont1,size=12)
    ax10 .plot(data.loc[a:b,p2].values,'k-',linewidth=2)
    ax10.set_ylabel(r'十米风速(m/s)', fontproperties=zhfont1, size=12)
    ax20 .plot(data.loc[a:b,p3].values,'k-',linewidth=2)
    ax20.set_ylabel(r'气压(hPa)', fontproperties=zhfont1, size=12)
    ax30 .plot(data.loc[a:b,p4].values,'k-',linewidth=2)
    ax30.set_ylabel(r'相对湿度(%)', fontproperties=zhfont1, size=12)
    x_lable=list(data.loc[a:b,p6].values[0:72:10])
    print(x_lable)
    # x_lable.append(data.loc[a:b,p6].values[0])
    new_x=sorted(x_lable)
    print(type(new_x))
    plt.xlim(0,71)
    ax30.set_xlabel('日期', fontproperties=zhfont1, size=12)
    ax30.set_xticklabels(new_x, fontproperties=zhfont1, size=12)
    print(new_x)
    plt.savefig(r'D:pycharm_project1205mangshipngqi_2.png')
    plt.show()


    def draw_1(data,a,b,p1,p2,p3,p4,p5,p6):
    fig,(ax00, ax10, ax20, ax30,ax40) = plt.subplots(5, 1, sharex=True,figsize=(10, 11))
    # fig, ax = plt.subplots(4, 1, figsize=(10, 11))
    ax00 .plot(data.loc[a:b,p1].values,'k-',linewidth=2)
    ax00.set_ylabel(r'$PM_{2.5}$'+r'($mu{g/m}^{3}$)',fontproperties=zhfont1,size=12)
    ax10 .plot(data.loc[a:b,p2].values,'k-',linewidth=2)
    ax10.set_ylabel(r'$PM_{10}$'+r'($mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
    ax20 .plot(data.loc[a:b,p3].values,'k-',linewidth=2)
    ax20.set_ylabel(r'CO'+r'($m{g/m}^{3}$)', fontproperties=zhfont1, size=12)
    ax30 .plot(data.loc[a:b,p4].values,'k-',linewidth=2)
    ax30.set_ylabel(r'$SO_{2}$'+r'($mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
    ax40.plot(data.loc[a:b, p5].values,'k-',linewidth=2)
    ax40.set_ylabel(r'$NO_{2}$'+r'($mu{g/m}^{3}$)', fontproperties=zhfont1, size=12)
    x_lable = list(data.loc[a:b, p6].values[0:72:10])
    print(x_lable)
    new_x = sorted(x_lable)
    print(type(new_x))
    plt.xlim(0, 71)
    ax40.set_xlabel('日期', fontproperties=zhfont1, size=12)
    ax40.set_xticklabels(new_x, fontproperties=zhfont1, size=12)
    print(new_x)
    plt.savefig(r'D:pycharm_project1205mangshipngqi_4.png')
    plt.show()




    if __name__ == '__main__':

    file=r'D:pycharm_project1205mangshidata1ms_0722.xlsx'
    data1=pd.read_excel(file,sheet_name='average')
    data2=pd.read_excel(file,sheet_name='56844')
    print(data1)
    # draw(data2,0,72,'TEM','WIN_S_Avg_10mi','PRS','RHU','','TimeStamp')
    # draw(data2,96,168,'TEM','WIN_S_Avg_10mi','PRS','RHU','','TimeStamp')
    # draw_1(data1,0,72,'pm25','pm10','co','so2','no2','aqitime')
    draw_1(data1,96,168,'pm25','pm10','co','so2','no2','aqitime')
    # print(data2)


  • 相关阅读:
    如何复制word的图文到UMEditor中自动上传
    如何复制word的图文到百度编辑器中自动上传
    如何复制word的图文到百度ueditor中自动上传
    java实现大文件上传源码
    java实现大文件上传控件
    java实现大文件上传组件
    java实现大文件上传插件
    html 常用标签及基本用法
    Web最佳实践阅读总结(1)
    基于DevOps理论与人工智能技术的银行业务可用性管控
  • 原文地址:https://www.cnblogs.com/avivi/p/11238144.html
Copyright © 2011-2022 走看看