pandas .plot() x-axis tick frequency — how can I show more ticks?

后端 未结 4 1839
梦毁少年i
梦毁少年i 2020-12-09 04:44

I am plotting time series using pandas .plot() and want to see every month shown as an x-tick.

Here is the dataset structure

Here is the result of the .plo

4条回答
  •  不思量自难忘°
    2020-12-09 05:11

    If you want to just show more ticks, you can also dive deep into the structure of pd.plotting._converter:

    dai = ax.xaxis.minor.formatter.plot_obj.date_axis_info
    dai['fmt'][dai['fmt'] == b''] = b'%b'
    

    After plotting, the formatter is a TimeSeries_DateFormatter and _set_default_format has been called, so self.plot_obj.date_axis_info is not None. You can now manipulate the structured array .date_axis_info to be to your liking, namely contain less b'' and more b'%b'

提交回复
热议问题