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:
- fun
callable
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_label
str
, optional Variable name with which to store the object returned by fun. Defaults to
fun.__name__
.- data
xarray.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_data
xarray.Dataset
orstr
, 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 ofdata
.- 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_aes
set
, optional Set of aesthetics present in
aes
that should be ignore for thismap
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 argumentsvar_name
,sel
andisel
. Moreover, if those were to be keys present in **kwargs their values in **kwargs would be ignored.- store_artistbool, default
True
- artist_dimsmapping of {hashable
int
}, 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
ofDataset
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 indata
will raise an error.
- fun
See also
map_over_plots