Let's go first (Tue in Figure Tuesday):
Both Pandas and matplotlib.dates use matplotlib.units to position the scale.
Matplotlib.dates can easily set the scale manually, while pandas seems to automatically adjust the format.
Directly on the code bar:
#-*-coding:utf-8-*-"""Created on Tue Dec 10:43:01 2015@author:vgis"""ImportNumPy as NPImportPandas as PDImportMatplotlib.pyplot as PltImportMatplotlib.dates as Datesidx= Pd.date_range ('2011-05-01','2011-07-01') s= PD. Series (len (idx)), index= Np.random.randnidx) FIG, ax=plt.subplots () ax.plot_date (Idx.to_pydatetime (), S,'v -') Ax.xaxis.set_minor_locator (dates. Weekdaylocator (Byweekday= (1), Interval=1) ) Ax.xaxis.set_minor_formatter (dates. Dateformatter ('%d\n%a')) Ax.xaxis.grid (True, which="Minor") Ax.yaxis.grid () ax.xaxis.set_major_locator (dates. Monthlocator ()) Ax.xaxis.set_major_formatter (dates. Dateformatter ('\n\n\n%b\n%y')) Plt.tight_layout () plt.show ()
#参考 #
- Http://stackoverflow.com/questions/12945971/pandas-timeseries-plot-setting-x-axis-major-and-minor-ticks-and-labels
Pandas time Series data plotting x-axis major and minor ticks