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 instatiates a chart 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:
vizdatatree.DataTree

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

aesdatatree.DataTree

Information about aesthetic mapping as a DataTree.

__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_dtdatatree.DataTree

DataTree object with which to populate the viz attribute.

aes_dtdatatree.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[, var_name, aes, ...])

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

allocate_artist(fun_label, data, all_loop_dims)

Allocate an artist in the viz DataTree.

generate_aes_dt([aes])

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(var_name)

Get the viz Dataset that corresponds to the provided variable.

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

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

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

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

plot_iterator([ignore_aes, coords])

Build a generator to loop over all plots in the PlotCollection.

rename_artists([name_dict])

Rename artist data variables in the viz DataTree.

show()

Call the backend function to show this chart.

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.

base_loop_dims

Dimensions over which one should always loop over when using this PlotCollection.

coords

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

data

Dataset to be used as data for plotting.

viz

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