
Я придумал эту странную ось вокруг всех построенных мною подграфиков, которая пронумерована от 0 до 1.
Я попробовал упростить код, например. удаление построения графика через цикл for и т. д., но оно все равно строится.
Есть какие-нибудь предложения или идеи по этому поводу? Спасибо.
fig, ax = plt.subplots(figsize=(ncols*4,nrows*4))
#plt.subplots_adjust(wspace=0.0001,hspace=0.2)
plt.suptitle('Profiles \n run=%s'%(run), fontsize=10)
ibeg=1 ; iend=len(dtimes)+1
for i,idt in zip(range(ibeg,iend),range(0,len(dtimes))):
ax=plt.subplot(nrows, ncols,i)
dtime=dtimes[idt]
df=pd.read_excel('plots/%s/model_temp_profiles.xlsx'%run, sheet_name=dtime)
line1=ax.plot(df['TEMPERATURE'],df['depth'], color='black', linewidth=2, label='Temp. model')
lines=line1
[![enter image description here][1]][1]
ax.set_xlim(min_temp,max_temp)
ax.set_ylim(-0.1,max_depth)
#-adjust y and x labels and ticks
if i==ibeg or i in [5,9,13,17,21]: #- first column subplots
ax.set_ylabel('depth (m)', fontsize=9)
else: #-other subplots
ax.tick_params(left=False, labelleft=False)
ax.set_xlabel('degC', fontsize=9)
#ax.set_yticks(np.arange(min(depths), max(depths), 5.0))
ax.set_xticks(np.arange(0, max_temp, 5.0))
#- prepare legend
labs=[l.get_label() for l in lines]
ax.legend(lines, labs, loc=4, frameon=True, fontsize=10)
ax.grid(color='grey',linestyle=':', linewidth=0.2)
ax.set_title('Temp.\n%s' %dtime, x=x_title, y=y_title, fontsize=10,\
bbox=dict(facecolor='white', alpha=0.5, edgecolor='none'))
ax.invert_yaxis()
plt.savefig('plots/%s/profiles.png' %(run), dpi=600)
Подробнее здесь: https://stackoverflow.com/questions/792 ... rom-0-to-1
Мобильная версия