【python】多子图共享x轴

ori = pd.DataFrame()
filled = pd.DataFrame()
xticks= []
for i in os.listdir(path):
    s = pd.read_csv(os.path.join(path,i))
    ori = s.loc[s['LE_F_MDS_QC']==0,['TIMESTAMP_START','LE_F_MDS']]
    filled = s.loc[s['LE_F_MDS_QC']!=0,['TIMESTAMP_START','LE_F_MDS']]

    s['TIMESTAMP_START'] = pd.to_datetime(s['TIMESTAMP_START'])
    s['year'] = s['TIMESTAMP_START'].dt.year
    

    # 绘制散点图
    
    fig ,ax = plt.subplots(3,1,sharex='col',figsize=(25,9),dpi=300)
    ax0 = ax[0]
    ax0.plot( 'LE_F_MDS', data=ori, linestyle='none',marker='o')
    
    ax1 = ax[1]
    ax1.plot(  'LE_F_MDS', data=filled, color='#ff7f0e',linestyle='none', marker='o')
    
    ax2 = ax[2]
    ax2.plot(  'LE_F_MDS', data=s, alpha=0.6, linestyle='none', marker='o')
    ax2.plot( 'LE_F_MDS', data=filled, alpha=0.6, linestyle='none', marker='o')
    
    ax0.set_ylabel('in-situ', fontsize=19)
    ax1.set_ylabel('gap-filled', fontsize=19)
    ax2.set_ylabel('Original dataset', fontsize=19)
    
    ax2.set_xticks([0,365*48,365*48*2,365*48*3,365*48*4])
    ax2.set_xticklabels(range(s['year'].min()-1,s['year'].max()+1),fontproperties='Times New Roman',size=19)
    ax2.set_xlabel('Year', fontsize=19)
    plt.show()
    
    

你可能感兴趣的:(python,开发语言)