arviz_plots.PlotCollection

arviz_plots.PlotCollection#

class arviz_plots.PlotCollection(data, viz_dt, aes_dt=None, aes=None, backend=None, **kwargs)[source]#

Low level base class for plotting with xarray Datasets.

This class instantiates a figure with multiple plots in it and provides methods to loop over these plots and the provided data syncing each plot and data subset to user given aesthetics.

Attributes:
vizxarray.DataTree

Information about the visual elements in the plot as a DataTree.

aesxarray.DataTree

Information about aesthetic mapping as a DataTree.

See also

arviz_plots.PlotMatrix

Pairwise facetting manager

__init__(data, viz_dt, aes_dt=None, aes=None, backend=None, **kwargs)[source]#

Initialize a PlotCollection.

It is not recommeded to initialize PlotCollection objects directly. Use its classmethods wrap and grid instead.

Parameters:
dataxarray.Dataset

The data from which viz_dt was generated and from which to generate the aesthetic mappings.

viz_dtxarray.DataTree

DataTree object with which to populate the viz attribute.

aes_dtxarray.DataTree, optional

DataTree object with which to populate the aes attribute. If given, the aes argument and all **kwargs are ignored.

aesmapping of {strlist of hashable}, optional

Dictionary with aesthetics as keys and as values a list of the dimensions it should be mapped to. See generate_aes_dt for more details.

backendstr, optional

Plotting backend. It will be stored and passed down to the plotting functions when using methods like map.

**kwargsmapping, optional

Dictionary with aesthetics as keys and as values a list of the values that should be taken by that aesthetic.

Methods

__init__(data, viz_dt[, aes_dt, aes, backend])

Initialize a PlotCollection.

add_legend(dim[, aes, artist_kwargs, title, ...])

Add a legend for the given visual/aesthetic to the plot.

allocate_artist(fun_label, data, all_loop_dims)

Allocate an visual in the viz DataTree.

generate_aes_dt(aes[, data])

Generate the aesthetic mappings.

get_aes_as_dataset(aes_key)

Get the values of the provided aes_key for all variables as a Dataset.

get_aes_kwargs(aes, var_name, selection)

Get the aesthetic mappings for the given variable and selection as a dictionary.

get_target(var_name, selection)

Get the target that corresponds to the given variable and selection.

get_viz(artist_name[, var_name, sel])

Get element from .viz that corresponds to the provided subset.

grid(data[, cols, rows, backend, figure_kwargs])

Instatiate a PlotCollection and generate a plot grid iterating over rows and columns.

map(fun[, fun_label, data, coords, ...])

Apply the given plotting function to all plots with the corresponding aesthetics.

rename_visuals([name_dict])

Rename visual data variables in the viz DataTree.

savefig(filename, **kwargs)

Call the backend function to save this figure.

show()

Call the backend function to show this figure.

store_in_artist_da(aux_artist, fun_label, ...)

Store the visual object of var_name`+`sel combination in fun_label variable.

update_aes([ignore_aes, coords])

Update list of aesthetics after indicating ignores and extra subsets.

update_aes_from_dataset(aes_key, dataset)

Update the values of aes_key with those in the provided Dataset.

wrap(data[, cols, col_wrap, backend, ...])

Instatiate a PlotCollection and generate a plot grid iterating over subsets and wrapping.

Attributes

aes

Information about aesthetic mapping as a DataTree.

aes_set

Return all aesthetics with a mapping defined as a set.

coords

Information about slicing operation to always be applied on the PlotCollection.

data

Dataset to be used as data for plotting.

facet_dims

Dimensions over which one should loop for facetting when using this PlotCollection.

viz

Information about the visual elements in the plot as a DataTree.