我知道重叠的刻度标签上已经有很多问题要问。但是我的问题有所不同(请参见红色框和重叠的刻度标签,这些标签本应来自一月十二月。
使用的数据框:
Month_day Temp_Max_2015 Temp_Min_2015 Temp_Max Temp_Min
0 05-10 29.4 NaN 29.4 -1.7
1 05-17 30.0 NaN 30.0 -1.0
2 08-14 31.7 NaN 31.7 5.0
3 09-27 27.8 NaN 27.8 3.3
... ... ... ... ...
361 12-28 NaN NaN 19.4 -16.6
362 12-29 NaN NaN 12.8 -15.0
363 12-30 NaN NaN 11.7 -14.4
364 12-31 NaN NaN 13.9 -15.0
绘图代码:
plt.plot(lplot['Month_day'],lplot[['Temp_Max','Temp_Min']])
plt.scatter(y=lplot['Temp_Max_2015'],x=lplot['Month_day'] , s=20, color='blue')
plt.scatter(y=lplot['Temp_Min_2015'],x=lplot['Month_day'], s=20, color='green')
ax = plt.gca()
plt.title('High and low Temperatures by\n day over the Period 2005-2014',fontsize=13)
plt.ylabel('Temperature (Tenth of Degrees C$^{\circ}$)',fontsize=10,alpha=0.8)
plt.xlabel('Months',fontsize= 10,alpha=0.8)
plt.gca().get_lines()[0].set_color('#FF0000')
plt.legend()
plt.legend(['High Temperature','Low Temperature','High temp record broken (2015)','Low temp record broken (2015)'])
plt.gca().fill_between(lplot.index,lplot['Temp_Max'],lplot['Temp_Min'],facecolor='#FFFB00',alpha=0.49)
ax.set_xticklabels(np.array(['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']))
ax.set_facecolor('white')
for spine in plt.gca().spines.values():
spine.set_visible(False)
plt.tick_params(axis='both',which='both',left=False,bottom=False)
plt.savefig('plot2')
plt.show()
plt.close()
谢谢您的帮助。