Plot time series with filled error bounds
- plot_utils.fill_timeseries(time_series, upper_bound, lower_bound, date_fmt=None, fig=None, ax=None, figsize=(10, 3), dpi=100, xlabel='Time', ylabel=None, line_label=None, shade_label=None, color='orange', lw=3, ls='-', fontsize=12, title=None, xgrid_on=True, ygrid_on=True)[source]
Plot time series as a line and then plot the upper and lower bounds as shaded areas.
- Parameters:
time_series (pandas.Series) – A pandas Series, with index being date.
upper_bound (pandas.Series) – Upper bounds of the time series, must have the same length as
time_series
.lower_bound (pandas.Series) – Lower bounds of the time series, must have the same length as
time_series
.date_fmt (str) – Date format specifier, e.g., ‘%Y-%m’ or ‘%d/%m/%y’.
fig (matplotlib.figure.Figure or
None
) – Figure object. If None, a new figure will be created.ax (matplotlib.axes._subplots.AxesSubplot or
None
) – Axes object. If None, a new axes will be created.figsize ((float, float)) – Figure size in inches, as a tuple of two numbers. The figure size of
fig
(if notNone
) will override this parameter.dpi (float) – Figure resolution. The dpi of
fig
(if notNone
) will override this parameter.xlabel (str) – Label of X axis. Usually “Time” or “Date”.
ylabel (str) – Label of Y axis. Usually the meaning of the data (e.g., “Gas price [$]”).
line_label (str) – Label of the line, for plotting legends.
shade_label (str) – Label of the shade, for plotting legends.
color (str or list or tuple) – Color of line. If None, let Python decide for itself.
lw (scalar) – Line width of the line that represents time_series.
ls (str) – Line style of the line that represents time_series.
fontsize (scalar) – Font size of the texts in the figure.
title (str) – Figure title.
xgrid_on (bool) – Whether or not to show vertical grid lines (default:
True
).ygrid_on (bool) – Whether or not to show horizontal grid lines (default:
True
).
- Returns:
fig (matplotlib.figure.Figure) – The figure object being created or being passed into this function.
ax (matplotlib.axes._subplots.AxesSubplot) – The axes object being created or being passed into this function.