Implement auto-encoding of hue, col, row, frames … specifiers in generic plot functions
The generic facet_grid
and errorbar
plots both allow specifying data dimensions that are to be associated with different representation properties. Currently, one either has to rely on xarray doing everything (kind = None
) or, if kind
is set, one frequently needs to set the remaining representation specifiers (hue
, col
, row
, frames
) manually (otherwise xarray complains).
Being able to automatically set these would greatly simplify plots in scenarios where the additional dimensions frequently vary, e.g. when doing parameter sweeps.
Proposal
- Implement a function that inspects the available data dimensions and automatically chooses which one to use for
hue
,col
,row
,frames
...- It should be possible to declare which specifiers are needed and in which order they should be populated:
- Suggested order:
hue
,col
,row
,frames
- The data dimensions should be populated in order of their size, i.e.: a dimension with many coordinates is associated with
hue
rather thancol
.
- Suggested order:
- Manually declared specifier values
- It should only set the free dimensions, i.e. those not already set manually. This
- There need be defaults depending on
kind
:hue
is only supported for line plots, for example - Bonus: If
row
is not needed, allow to automatically choosecol_wrap
to get a more "square"-like plot instead of having a very wide plot (with many columns)
- It should be possible to declare which specifiers are needed and in which order they should be populated:
- Implement this as a free function that can be shared between generic plotting functions.
- Suggested names:
- For the function:
determine_encoding
- For the argument controlling this behaviour:
auto_encode: Union[bool, dict]
, with the bool simply enabling/disabling the feature and dict allowing to pass further options.
- For the function: