Time series
timeseries (matplotlib, one or two axes, line / scatter / bar styles),
timeseries_stacked, timeseries_template, and the Plotly
timeseries_interactive. Usage: Visualization.
AeroViz.plot.timeseries.timeseries
Attributes
default_bar_kws
module-attribute
default_scatter_kws
module-attribute
default_insert_kws
module-attribute
default_insert_kws = dict(width='1.5%', height='100%', loc='lower left', bbox_to_anchor=(1.01, 0, 1.2, 1), borderpad=0)
Classes
Color
Unit
Functions:
set_figure
set_figure(func=None, *, figsize: tuple | None = None, fs: int | None = None, fw: str = None, autolayout: bool = True)
auto_label_pct
auto_label_pct(pct, symbol: bool = True, include_pct: bool = False, ignore: Literal['inner', 'outer'] = 'inner', value: float = 2)
linear_regression_base
linear_regression_base(x_array: ndarray, y_array: ndarray, columns: str | list[str] | None = None, positive: bool = True, fit_intercept: bool = True)
_wind_arrow
Plot wind arrows on a scatter plot.
:param ax: matplotlib axes :param df: pandas DataFrame :param y: column name for wind speed :param c: column name for wind direction :param scatter_kws: keyword arguments for scatter plot :param cbar_kws: keyword arguments for colorbar :param inset_kws: keyword arguments for inset axes
process_timeseries_data
timeseries
timeseries(df: DataFrame, y: list[str] | str, y2: list[str] | str = None, yi: list[str] | str = None, color: list[str] | str | None = None, label: list[str] | str | None = None, rolling: int | str | None = 3, interpolate_limit: int | None = 6, major_freq: str = '1MS', minor_freq: str = '10d', style: list[Literal['scatter', 'bar', 'line', 'arrow']] | str | None = None, ax: Axes | None = None, set_xaxis_visible: bool | None = None, legend_loc: Literal['best', 'upper right', 'upper left', 'lower left', 'lower right'] = 'best', legend_ncol: int = 1, **kwargs) -> tuple[Figure, Axes]
Plot the timeseries data with the option of scatterplot, barplot, and lineplot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The data to plot. |
required |
y
|
list[str] | str
|
The primary y-axis data columns. |
required |
y2
|
list[str] | str
|
The secondary y-axis data columns. Defaults to None. |
None
|
yi
|
list[str] | str
|
The components for percentage calculation. Defaults to None. |
None
|
color
|
str
|
The column for color mapping or the color. Defaults to None. |
None
|
label
|
str
|
The label for the legend. Defaults to None. |
None
|
rolling
|
str | int | None
|
Rolling window size for smoothing. Defaults to None. |
3
|
interpolate_limit
|
int
|
Interpolation limit for missing values. Defaults to None. |
6
|
major_freq
|
str
|
Frequency for x-axis ticks. Defaults to '1MS'. |
'1MS'
|
minor_freq
|
str
|
Frequency for x-axis minor ticks. Defaults to '10d'. |
'10d'
|
style
|
Literal['scatter', 'bar', 'line'] | None
|
Style of the plot. Defaults to 'scatter'. |
None
|
ax
|
Axes | None
|
Matplotlib Axes object to plot on. Defaults to None. |
None
|
set_xaxis_visible
|
bool | None
|
Whether to set x-axis visibility. Defaults to None. |
None
|
legend_loc
|
Literal['best', 'upper right', 'upper left', 'lower left', 'lower right']
|
Location of the legend. Defaults to 'best'. |
'best'
|
legend_ncol
|
int
|
Number of columns in the legend. Defaults to 1. |
1
|
**kwargs
|
Additional keyword arguments for customization.
|
fig_kws : dict, optional Additional keyword arguments for the figure. Defaults to {}. scatter_kws : dict, optional Additional keyword arguments for the scatter plot. Defaults to {}. bar_kws : dict, optional Additional keyword arguments for the bar plot. Defaults to {}. ax_plot_kws : dict, optional Additional keyword arguments for the primary y-axis plot. Defaults to {}. ax2_plot_kws : dict, optional Additional keyword arguments for the secondary y-axis plot. Defaults to {}. cbar_kws : dict, optional Additional keyword arguments for the colorbar. Defaults to {}. inset_kws : dict, optional Additional keyword arguments for the inset axes. Defaults to {}. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
AxesSubplot
|
Matplotlib AxesSubplot. |
Example
timeseries(df, y='WS', color='WD', scatter_kws=dict(cmap='hsv'), cbar_kws=dict(ticks=[0, 90, 180, 270, 360]), ylim=[0, None])
timeseries_stacked
timeseries_stacked(df, y: list[str] | str, yi: list[str] | str, label: list[str] | str, plot_type: Literal['absolute', 'percentage', 'both'] | str = 'both', rolling: int | str | None = 4, interpolate_limit: int | None = 4, major_freq: str = '10d', minor_freq: str = '1d', support_df: DataFrame | None = None, ax: Axes | None = None, savefig: str | Path | None = None, **kwargs) -> tuple[Figure, Axes]
AeroViz.plot.timeseries.timeseries_stacked
timeseries_stacked(df, y: list[str] | str, yi: list[str] | str, label: list[str] | str, plot_type: Literal['absolute', 'percentage', 'both'] | str = 'both', rolling: int | str | None = 4, interpolate_limit: int | None = 4, major_freq: str = '10d', minor_freq: str = '1d', support_df: DataFrame | None = None, ax: Axes | None = None, savefig: str | Path | None = None, **kwargs) -> tuple[Figure, Axes]
AeroViz.plot.timeseries.timeseries_template
Interactive viewer
timeseries_interactive renders an interactive Plotly chart for a
RawDataReader result — one trace per column, with the legend acting as the
column selector (click an entry to show/hide it). Pan, zoom, hover and a time
range-slider are built in, and the figure can be saved as a standalone HTML
file. It returns the Plotly figure, not (fig, ax).
from AeroViz import RawDataReader
from AeroViz.plot import timeseries_interactive
df = RawDataReader('AE33', '/data/AE33') # native resolution, full coverage
timeseries_interactive(df, columns=['eBC', 'BC1', 'BC6', 'AAE']) # click legend to toggle
timeseries_interactive(df, save='ae33.html', show=False) # export to HTML
AeroViz.plot.timeseries_interactive
timeseries_interactive(df: DataFrame, columns: list | None = None, *, save: str | None = None, show: bool = True, title: str | None = None)
Interactive timeseries plot (Plotly); the legend toggles columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
A RawDataReader result (DatetimeIndex). |
required |
columns
|
list
|
Columns to plot. Defaults to the numeric, non-size-bin columns (size
bins like |
None
|
save
|
str
|
If given, write the figure to this standalone HTML path. |
None
|
show
|
bool
|
Display the figure (inline in notebooks, or open a browser tab). |
True
|
title
|
str
|
Figure title; defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure, for further customisation. |