python - Stretching Data Over Entire x-axis -
i plotted data using matplotlib , have large whitespace gap on end. ideas on how rid of it? (204 values plotted)
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()
as @plonser said above,
ax.set_xlim(0,205)
Comments
Post a Comment