Pandas time Series data plotting x-axis major and minor ticks

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.