问题描述
我一直在网上寻求帮助,但我所看到的任何东西都无法帮助我在 xticks 之间添加空间而不会丢失 x 轴上的任何 xtick 标签。这是我的代码以及我试图将下图变为当前布局的内容。是否有自动调整有效? “plt.tight_layout”应该这样做,但似乎对我不起作用。感谢您的帮助。并且,plt.suptitle 不以月份(二月)为中心。
#CALC VARIABILITY AND PLOT BoxPLOTS for ea month
sitenames = df3.plant_name.unique().tolist()
months = ['JANUARY','FEBRUARY','marcH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER']
from datetime import datetime
monthn = datetime.Now().month
newList = list()
for i in range(monthn-1):
newList.append(months[(i)%12])
print(newList)
for i,month in enumerate(newList,1):
#plt.figure()
#fig,ax = plt.subplots()
#ax = df3[df3['month']==i].Boxplot(by='plant_name',column='Var',grid=False)
datey = datetime.today().strftime("%Y")
ax = df3[df3['month']==i].plot(kind='scatter',x='plant_name',y='Var',marker='.',s=5,grid=False)
stdp[stdp['month']==i].plot(kind='scatter',x = 'plant_name',color='k',marker='_',s=200,label = '1+Std',grid=False,ax=ax)
stdn[stdn['month']==i].plot(kind='scatter',label = '1-Std',ax=ax)
stdp2[stdp2['month']==i].plot(kind='scatter',s=50,label = '2+Std',ax=ax)
stdn2[stdn2['month']==i].plot(kind='scatter',label = '2-Std',ax=ax)
medn[medn['month']==i].plot(kind='scatter',color='g',s=90,label = 'p50',ax=ax)
df3c[df3c['month']==i].plot(kind='scatter',color='r',label =
datey,ax=ax)
# Save the default tick positions,so we can reset them...
locs,labels = plt.xticks()
plt.xticks(rotation=90,ha='center')
plt.suptitle('1991-2020 ERA5 WIND PRODUCTION',y=1)
plt.title(months[i-1])
plt.xlabel('SITE')
plt.ylabel('VARIABILITY')
#plt.legend()
ax.legend(loc='center left',bBox_to_anchor=(1,0.5),prop={'size': 8})
plt.tick_params(axis='x',which='major',labelsize=10)
plt.tight_layout(rect=[0,2,1])
plt.subplots_adjust(bottom=0.1)
没有“plot_tight_layout(rect[0,1])”
并且,包括“plot_tight_layout(rect[0,1])”:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)