dantro.plot_creators.ext_funcs.generic module¶
Generic, DAG-supporting plots
-
dantro.plot_creators.ext_funcs.generic.facet_grid(*, data: dict, hlpr: dantro.plot_creators._plot_helper.PlotHelper, kind: str = None, frames: str = None, suptitle_kwargs: dict = None, **plot_kwargs)[source]¶ This is a generic FacetGrid plot function with preprocessed DAG data.
This function calls the data[‘data’].plot function if no plot kind is given else the specified data[‘data’].plot.<kind> function. It is designed for xarray plotting i.e. xarray.DataArray and xarray.Dataset plotting capabilities. Specifying the kind of plot requires the data to either be an xarray.DataArray or xarray.Dataset of specific dimensionality, see the correponding documentation.
In most cases, the function creates a so-called FacetGrid <http://xarray.pydata.org/en/stable/generated/xarray.plot.FacetGrid.html>_ object that automatically layouts and chooses a visual representation that fits the dimensionality of the data. To specify which data dimension should be represented in which way, it supports a basic declarative syntax: via the optional keyword arguments
x,y,row,col, and/orhue(available options are listed in the corresponding plot function documentation), the data dimensions to represent in the corresponding way can be selected.dantro adds the
framesargument, which behaves in a similar way but leads to an animation being generated, thus opening up one further dimension of representation.Note
When specifying
frames, theanimationarguments need to be specified. See here for more information on the expected animation parameters.The value of the
animation.enabledkey is not relevant for this function; it will automatically enter or exit animation mode, depending on whether theframesargument is given or not. This uses the animation mode switching feature.Warning
Depending on
kindand the dimensionality of the data, some plot functions might create their own figure, disregarding any previously set up figure. This includes the figure from the plot helper.To control figure aesthetics, you can either specify matplotlib RC style parameters (via the
styleargument), or you can use theplot_kwargsto pass arguments to the respective plot functions. For the latter, refer to the respective documentation to find out about available arguments.- Parameters
data (dict) – The data selected by the DAG framework
hlpr (PlotHelper) – The plot helper
kind (str, optional) – The kind of plot to use. Options are:
contourf,contour,imshow,line,pcolormesh,step,hist,scatter. If None is given, xarray automatically determines it using the dimensionality of the data.frames (str, optional) – The data dimension from which to create frames. If given, this results in the creation of an animation. If not given, a single plot is generated.
suptitle_kwargs (dict, optional) – Key passed on to the PlotHelper’s
set_suptitlehelper function. Only used if animations are enabled. Thetitleentry can be a format string with the following keys, which are updated for each frame of the animation:dim,value. Default:{dim:} = {value:.3g}.**plot_kwargs – Passed on to
<data>.plotor<data>.plot.<kind>