当前位置:网站首页>并列图的画法,多排多列

并列图的画法,多排多列

2022-07-04 21:14:00 小蜗笔记

import matplotlib.pyplot as plt


plt.style.use('seaborn-whitegrid')
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
fig = plt.figure(figsize=(70, 60),dpi=60)

for i in range(1,42):
    ax = fig.add_subplot(7,6,i)
    ax.spines['bottom'].set_linewidth('1.0')#设置边框线宽为2.0
    ax.spines['bottom'].set_color('black')
    ax.spines['top'].set_linewidth('1.0')#设置边框线宽为2.0
    ax.spines['top'].set_color('black')
    ax.spines['right'].set_linewidth('1.0')#设置边框线宽为2.0
    ax.spines['right'].set_color('black')
    ax.spines['left'].set_linewidth('1.0')#设置边框线宽为2.0
    ax.spines['left'].set_color('black')
    plt.xticks(fontsize = 20)
    plt.yticks(fontsize = 20)

    plt.scatter(data_std_all[data_std_all['firm'] == i]['year'], data_std_all[data_std_all['firm'] == i]['tfpch'], c='black', edgecolors='black')
    plt.plot(data_std_all[data_std_all['firm'] == i]['year'], data_std_all[data_std_all['firm'] == i]['y_forecast'],color='black',linestyle = '-',linewidth=2, markersize=12)
    if len(data_std_all[(data_std_all['firm'] == i)&(data_std_all['group'] == 1)]['year']) !=0:
        plt.plot([data_std_all[(data_std_all['firm'] == i)&(data_std_all['group'] == 1)]['year'].iloc[0],data_std_all[(data_std_all['firm'] == i)&(data_std_all['group'] == 1)]['year'].iloc[0]],[-2.5,2.5],
             color='black',linestyle = '-.',linewidth=2, markersize=12)
    plt.ylim(-3, 3)
    plt.xlim(2009, 2022)
    plt.xticks(size=30)
    plt.yticks(size=30)
    plt.title(data_std_all[data_std_all['firm'] == i]['area'].iloc[0],size=30)
    
    
plt.show()
原网站

版权声明
本文为[小蜗笔记]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42830971/article/details/125581063