virocon.plotting module¶
Functions to plot distributions and contours.
- virocon.plotting.plot_2D_contour(contour, sample=None, design_conditions=None, semantics=None, swap_axis=False, ax=None)[source]¶
Plot a 2D contour.
- Parameters
contour (Contour) – The 2D contour that should be plotted.
sample (ndarray of floats, optional) – A 2D data sample that should be plotted along the contour. Shape: (number of realizations, 2)
design_conditions (array-like or boolean, optional) – Specified environmental conditions under which the system must operate. If an array it is assumed to be a 2D array of shape (number of points, 2) and should contain the precalculated design conditions. If it is True design_conditions are computed with default values and plotted. Otherwise, no design conditions will be plotted (the default).
semantics (dict, optional) – Generated model description. Defaults to None.
swap_axis (boolean, optional) – f True the second dimension of the model is plotted on the x-axis and the first on the y-axis. Otherwise, vice-versa. Defaults to False.
ax (matplotlib Axes, optional) – Matplotlib axes object to use for plotting. If None (default) a new figure will be created.
- Returns
The matplotlib axes objects plotted into.
(optional (the design_conditions if not None, yet to implement))
- virocon.plotting.plot_2D_isodensity(model, sample, semantics=None, swap_axis=False, limits=None, levels=None, ax=None, n_grid_steps=250)[source]¶
Plot isodensity contours and a data sample for a 2D model.
- Parameters
model (MultivariateModel) – The 2D model to use.
sample (ndarray of floats) – The 2D data sample that should be plotted.
semantics (dict, optional) – The description of the model. If None (the default) generic semantics will be used.
swap_axis (boolean, optional) – If True the second dimension of the model is plotted on the x-axis and the first on the y-axis. Otherwise, vice-versa. Defaults to False.
limits (list of tuples, optional) – Specifies in which rectangular region the density is calculated and plotted. If None (default) limits will be set automatically. Example: [(0, 20), (0, 12)]
levels (list of floats, optional) – The probability density levels that are plotted. If None (default) levels are set automatically. Example: [0.001, 0.01, 0.1]
n_grid_steps (int, optional) – The number of steps along each axis of the grid used to plot the contours. Defaults to 250.
ax (matplotlib Axes, optional) – Matplotlib axes object to use for plotting. If None (default) a new figure will be created.
- Return type
The used matplotlib axes object.
- virocon.plotting.plot_dependence_functions(model, semantics=None, par_rename={}, axes=None)[source]¶
Plot the fitted dependence functions of a model.
- Parameters
model (MultivariateModel) – The model with the fitted dependence functions.
semantics (dict, optional) – The description of the model. If None (the default) generic semantics will be used.
par_rename (dict, optional) – A dictionary that maps from names of conditional parameters to a string. If e.g. the model has a distribution with a conditional parameter named ‘mu’ one could change that in the plot to ‘$mu$’ with {‘mu’: ‘$mu$’}.
axes (list of matplotlib axes objects, optional) – If not further specified, the number of axes are dependent on the number of dimensions of the model. Defaults to None.
- Return type
The used matplotlib axes object.
- virocon.plotting.plot_histograms_of_interval_distributions(model, sample, semantics=None, plot_pdf=True)[source]¶
Plot histograms of all model dimensions.
If the model is conditional in a dimension all histograms per interval are plotted for that dimension. In such a case the fitted interval distributions are generally different from the final joint distribution.
- Parameters
model (MultivariateModel) – The model that was fitted to the dataset.
sample (ndarray) – The data that was used to fit the model.
semantics (dict, optional) – The description of the model. If None (the default) generic semantics will be used.
plot_pdf (boolean, optional) – Whether the fitted probability density should be plotted. Defaults to True.
- Return type
The used matplotlib axes objects.
- virocon.plotting.plot_marginal_quantiles(model, sample, semantics=None, axes=None)[source]¶
Plot all marginal quantiles of a model.
Plots the fitted marginal distribution versus a dataset in a quantile-quantile (QQ) plot.
- Parameters
model (MultivariateModel) – The model used to plot the marginal quantiles.
sample (ndarray of floats) – The environmental data sample that should be plotted against the fit. Shape: (sample_size, n_dim)
semantics (dict, optional) – The description of the model. If None (the default) generic semantics will be used. The structure is as follows: modeldesc = { “names” : [<Names of variables>], “symbols” : [<Description of symbols>], “units” : [<Units of variables>] }
axes (list, optional) – The matplotlib axes objects to plot into. One for each dimension. If None (the default) a new figure will be created for each dimension.
- Return type
The used matplotlib axes object.
Notes
When saving the resulting axes in a vector image format (pdf, svg) the sample will still be rasterized to reduce the file size. To prevent that, iterate over the axes and use
ax.get_lines()[0].set_rasterized(False)
.