Skip to content

Plotting

Plotting utilities.

Import as:

from covvfit import plot

covvfit.plotting._grid.ArrangedGrid dataclass

A two-dimensional grid of axes.

Attrs

fig: Matplotlib figure.

one-dimensional array of active axes,

with length equal to the number of active plots

axes_grid: two-dimensional array of all axes.

Note

The number of plots in axes_grid is typically greater than the one in axes, as axes_grid contains also the axes which are not active

map(self, func, arguments=None)

Applies a function to each active plotting axis.

Parameters:

Name Type Description Default
func Union[Callable[[matplotlib.axes._axes.Axes], NoneType], Callable[[matplotlib.axes._axes.Axes, Any]]]

function to be applied. It can have signature func(ax: plt.Axes) if arguments is None, which modifies the axis in-place.

If arguments is not None, then the function should have the signature func(ax: plt.Axes, argument) where argument is taken from the arguments list

required

covvfit.plotting._grid.arrange_into_grid(nplots, ncols=2, axsize=(2.0, 1.0), **kwargs)

Builds an array of plots to accommodate the axes listed.

Parameters:

Name Type Description Default
nplots int

number of plots

required
ncols int

number of columns

2
axsize tuple

axis size

(2.0, 1.0)
kwargs

keyword arguments to be passed to subplots_from_axsize. For example,

wspace=0.2,  # Changes the horizontal spacing
hspace=0.3,  # Changes the vertical spacing
left=0.5,    # Changes the left margin

{}

covvfit.plotting._grid.set_axis_off(ax, i=0, j=0)

Hides the axis.

Timeseries submodule

Import as

from covvfit import plot
plot_ts = plot.timeseries

covvfit.plot.timeseries.plot_fit(ax, ts, y_fit, *, colors, variants=None, linestyle='-', **kwargs)

Function to plot fitted values with customizable line type.

Parameters:

Name Type Description Default
ax matplotlib.axes

The axis to plot on.

required
ts array-like

Time series data.

required
y_fit array-like

Fitted values for each variant.

required
variants list

List of variant names.

None
colors list

List of colors for each variant.

required
linestyle str

Line style for plotting (e.g., '-', '--', '-.', ':').

'-'

covvfit.plot.timeseries.plot_complement(ax, ts, y_fit, color='grey', linestyle='-', **kwargs)

covvfit.plot.timeseries.plot_data(ax, ts, ys, colors, size=4.0, alpha=0.5, **kwargs)