arviz-devs / arviz-plots

ArviZ modular plotting
https://arviz-plots.readthedocs.io
Apache License 2.0
2 stars 2 forks source link

Define and document conventions on artist naming and keys for xyz_kwargs in plots module #66

Open OriolAbril opened 3 months ago

OriolAbril commented 3 months ago

Functions in plots module have aes_kwargs, plot_kwargs, stats_kwargs whose keys we need to define. We should define how we want those to behave and document whatever naming conventions we are using to then be able to ensure consistency across plots. Otherwise we'll end up having too many plots and it will no longer be possible to use something intuitive-ish and consistent.

Things I think we have been using quite consistently:

Open questions:

OriolAbril commented 3 months ago

Should there be some kind of syntactic sugar to set multiple keys to the same value?

For example, to disable the ci, point estimate and title in plot_dist, something like:

plot_kwargs = {key: False for key in ("credible_interval", "title", "point_estimate")}

One option could be to allow "," or "+" in the keys, so we then internally "explode" those composed keys into the multiple ones. Then, setting ci and title to color red and disabling remove axis and point estimate would be something like:

plot_kwargs = {"title,credible_interval": {"color": "red"}, "point_estimate,remove_axis": False}
OriolAbril commented 2 months ago

We had some discussion over a call, we think the main point that helps have an intuitive interface is having the same keys in both stats_kwargs and plot_kwargs whenever possible. Moreover, we prefer using a single key instead of multiple ones (e.g. single "density" key instead of "kde", "ecdf", "hist" depending on a kind parameter).

Regarding raising error, we should do that for invalid keys.

We'll also try the syntactic sugar mentioned above.

Implementation wise, there should be a helper function to take care of this as it will be common among all plots, something like proccess_kwargs(kwargs_dict: dict, valid_keys: Sequence) which returns a new dictionary. So it handles None->empty dict, dict->copy of dict and check keys + explode keys