leaspy.io.logs.visualization.plotting module

class Plotting(model, output_path='.', palette='tab10', max_colors=10)

Bases: object

Deprecated since version 1.2.

Class defining some plotting tools.

Parameters
modelleaspy Model

The model you want to do plots with.

output_pathstr (optional)

Folder where plots will be saved. If None, default to current working directory.

palettestr (palette name) or matplotlib.colors.Colormap (ListedColormap or LinearSegmentedColormap)

The palette to use.

max_colorsint > 0, optional (default, corresponding to model nb of features)

Only used if palette is a string

Methods

average_trajectory(**kwargs)

Plot the population average trajectories.

colors([at])

Wrapper over color_palette iterator to get colors

patient_observations(data[, patients_idx, ...])

Plot patient observations

patient_observations_reparametrized(data, ...)

Plot patient observations (reparametrized ages)

patient_trajectories(data, individual_parameters)

Plot patient observations together with model individual reconstruction

set_palette(palette[, max_colors])

Set palette of plots

average_trajectory(**kwargs)

Plot the population average trajectories. They are parametrized by the population parameters derived during the calibration.

Parameters
**kwargs
  • alpha: float, default 0.6

    Matplotlib’s transparency option. Must be in [0, 1].

  • linestyle: {‘-’, ‘–’, ‘-.’, ‘:’, ‘’, (offset, on-off-seq), …}

    Matplotlib’s linestyle option.

  • linewidth: float

    Matplotlib’s linewidth option.

  • features: list[str]

    Name of features (if set it must be a subset of model features) Default: all model features.

  • colors: list[str]

    Contains matplotlib compatible colors. At least as many as number of features.

  • labels: list[str]

    Used to rename features in the plot. Exactly as many as number of features. Default: raw variable name of each feature

  • ax: matplotlib.axes.Axes

    Axes object to modify, instead of creating a new one.

  • figsize: tuple of int

    The figure’s size.

  • save_as: str, default None

    Path to save the figure.

  • title: str

  • n_tpts: int

    Nb of timepoints in plot (default: 100)

  • n_std_left, n_std_right: float (default: 3 and 6 resp.)

    Time window around tau_mean, expressed as times of max(tau_std, 4)

Returns
matplotlib.axes.Axes
colors(at=None)

Wrapper over color_palette iterator to get colors

Parameters
atany legit color_palette arg (int, float or iterable of any of these) or None (default)

if None returns all colors of palette upto model dimension

Returns
colorssingle color tuple (RGBA) or np.array of RGBA colors (number of colors x 4)
patient_observations(data, patients_idx='all', individual_parameters=None, **kwargs)

Plot patient observations

Parameters
dataData
patients_idx‘all’ (default), str or list[str]

Patients to display (by their ID).

individual_parametersIndividualParameters or pandas.DataFrame (as may be outputed by ip.to_dataframe()) or dict (Pytorch ip format) or None (default)

If not None, observations are plotted with respect to reparametrized ages.

patient_observations_reparametrized(data, individual_parameters, patients_idx='all', **kwargs)

Plot patient observations (reparametrized ages)

cf. patient_observations, uniquely a reordering of arguments (and mandatory individual_parameters) for ease of use…

patient_trajectories(data, individual_parameters, patients_idx='all', reparametrized_ages=False, **kwargs)

Plot patient observations together with model individual reconstruction

Parameters
dataData
individual_parametersIndividualParameters or pandas.DataFrame (as may be output by ip.to_dataframe()) or dict (Pytorch ip format)
patients_idx‘all’ (default), str or list[str]

Patients to display (by their ID).

reparametrized_agesbool (default False)

Should we plot trajectories in reparam age or not? to study source impact essentially

**kwargs

cf. _plot_model_trajectories() In particular, pass marker=None if you don’t want observations besides model

set_palette(palette, max_colors=None)

Set palette of plots

Parameters
palettestr (palette name) or matplotlib.colors.Colormap (ListedColormap or LinearSegmentedColormap)

The palette to use.

max_colorsint > 0, optional (default, corresponding to model nb of features)

Only used if palette is a string