W3cubDocs

/Statsmodels

statsmodels.graphics.tsaplots.month_plot

statsmodels.graphics.tsaplots.month_plot(x, dates=None, ylabel=None, ax=None) [source]

Seasonal plot of monthly data

Parameters:
  • x (array-like) – Seasonal data to plot. If dates is None, x must be a pandas object with a PeriodIndex or DatetimeIndex with a monthly frequency.
  • dates (array-like, optional) – If x is not a pandas object, then dates must be supplied.
  • ylabel (str, optional) – The label for the y-axis. Will attempt to use the name attribute of the Series.
  • ax (matplotlib.axes, optional) – Existing axes instance.
Returns:
Return type:

matplotlib.Figure

Examples

>>> import statsmodels.api as sm
>>> import pandas as pd
>>> dta = sm.datasets.elnino.load_pandas().data
>>> dta['YEAR'] = dta.YEAR.astype(int).astype(str)
>>> dta = dta.set_index('YEAR').T.unstack()
>>> dates = pd.to_datetime(list(map(lambda x : '-'.join(x) + '-1',
...                                        dta.index.values)))
>>> dta.index = pd.DatetimeIndex(dates, freq='MS')
>>> fig = sm.graphics.tsa.month_plot(dta)

(Source code, png, hires.png, pdf)

../_images/graphics_month_plot.png

© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.graphics.tsaplots.month_plot.html