在整个x轴上拉伸数据

时间:2015-04-22 17:44:25

标签: python matplotlib plot

我使用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()

enter image description here

1 个答案:

答案 0 :(得分:1)

正如@plonser上面所说,

ax.set_xlim(0,205)
相关问题