bff.plot.plot_series¶
-
bff.plot.
plot_series
(df, column, groupby=None, with_sem=False, with_peaks=False, with_missing_datetimes=False, distance_scale=0.04, label_x='Datetime', label_y=None, title='Plot of series', ax=None, color='#3F5D7D', loc='best', rotation_xticks=None, grid='y', figsize=14, 6, dpi=80, style='default', **kwargs)¶ Plot time series with datetime with the given resample (groupby).
- Parameters
df (pd.DataFrame) – DataFrame to plot, with datetime as index.
column (str) – Column of the DataFrame to display.
groupby (str, optional) – Grouping for the resampling by mean of the data. For example, can resample from seconds (‘S’) to minutes (‘T’). By default, no resampling is applied.
with_sem (bool, default False) – Display the standard error of the mean (SEM) if set to true. Only possible if a resampling has been done.
with_peaks (bool, default False) – Display the peaks of the serie if set to true.
with_missing_datetimes (bool, default False) – Display the missing datetimes with vertical red lines. Only possible if a resampling has been done.
distance_scale (float, default 0.04) – Scaling for the minimal distance between peaks. Only used if with_peaks is set to true.
label_x (str, default 'Datetime') – Label for x axis.
label_y (str, default None) – Label for y axis. If None, will take the column name as label.
title (str, default 'Plot of series') – Title for the plot (axis level).
ax (plt.axes, optional) – Axes from matplotlib, if None, new figure and ax will be created.
color (str, default '#3F5D7D') – Default color for the plot.
loc (str or int, default 'best') – Location of the legend on the plot. Either the legend string or legend code are possible.
rotation_xticks (float, optional) – Rotation of x ticks if any. Set to 90 to put them vertically.
grid (str or None, default 'y') – Axis where to activate the grid (‘both’, ‘x’, ‘y’). To turn off, set to None.
figsize (Tuple[int, int], default (14, 6)) – Size of the figure to plot.
dpi (int, default 80) – Resolution of the figure.
style (str, default 'default') – Style to use for matplotlib.pyplot. The style is use only in this context and not applied globally.
**kwargs – Additional keyword arguments to be passed to the plt.plot function from matplotlib.
- Returns
Axes object or array of Axes objects returned by the plt.subplots function.
- Return type
plt.axes
Examples
>>> df_acceleration = fake.get_data_with_datetime_index(...) >>> _, axes = plt.subplots(nrows=3, ncols=1, figsize=(14, 20), dpi=80) >>> colors = {'x': 'steelblue', 'y': 'darkorange', 'z': 'darkgreen'} >>> for i, acc in enumerate(['x', 'y', 'z']): ... plot_series(df_acceleration, acc, groupby='T', ... ax=axes[i], color=colors[acc])