arviz_plots.PlotCollection.map

arviz_plots.PlotCollection.map#

PlotCollection.map(fun, fun_label=None, *, data=None, loop_data=None, extra_data=None, coords=None, ignore_aes=frozenset({}), subset_info=False, store_artist=True, artist_dims=None, **kwargs)[source]#

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

Parameters:
funcallable

Function with signature fun(da, target, **fun_kwargs) which should be applied for all combinations of plot and aesthetic. The object returned by fun is assumed to be a scalar unless artist_dims are provided. There is also the option of adding extra required keyword arguments with the subset_info flag.

fun_labelstr, optional

Variable name with which to store the object returned by fun. Defaults to fun.__name__.

dataxarray.Dataset, optional

Data to be subsetted at each iteration and to pass to fun as first positional argument. Defaults to the data used to initialize the PlotCollection.

loop_dataxarray.Dataset or str, optional

Data which will be used to loop over and generate the information used to subset data. It also accepts the value “plots” as a way to indicate fun should be applied exactly once per plot. Defaults to the value of data.

coordsmapping, optional

Dictionary of {coordinate names : coordinate values} that should be used to subset the aes, data and viz objects before any facetting or aesthetics mapping is applied.

ignore_aesset, optional

Set of aesthetics present in aes that should be ignore for this map call.

subset_infobool, default False

Add the subset info from arviz_base.xarray_sel_iter to the keyword arguments passed to fun. If true, then fun must accept the keyword arguments var_name, sel and isel. Moreover, if those were to be keys present in **kwargs their values in **kwargs would be ignored.

store_artistbool, default True
artist_dimsmapping of {hashableint}, optional

Dictionary of sizes for proper allocation and storage when using map with functions that return an array of artist.

**kwargsmapping, optional

Keyword arguments passed as is to fun. Values within **kwargs with DataArray of Dataset type will be subsetted on the current selection (if possible) before calling fun. Slicing with dims and coords is applied to the relevant subset present in the xarray object so dimensions with mapped asethetics not being present is not an issue. However, using Datasets that don’t contain all the variable names in data will raise an error.

See also

map_over_plots