我使用Matplotlib绘制了一些数据,最后有这么大的空白间隙。关于如何摆脱它的任何想法? (绘制204个值)
fig, ax = plt.subplots()
ax.plot(osnow,'r-',label="Observations")
ax.plot(rsnow,'b-',label='MERRA')
plt.xlabel('Year')
plt.ylabel('Snow Depth (cm)')
plt.title('Station '+str(stations[c])+' Snow Depth Correlations')
ax.set_xticks(np.arange(0,205,12))
ax.set_xticklabels(['1979','1980','1981','1982','1983','1984','1985','1986','1987','1988',
'1989','1990','1991','1992','1993','1994','1995','1996'], fontsize = 'small')
ax.text(30.0,35.0,'R = '+str(corr[0])+'', ha='center', va='center')
plt.legend(loc='best')
plt.show()
答案 0 :(得分:1)
正如@plonser上面所说,
ax.set_xlim(0,205)