arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.59k stars 393 forks source link

Add a backend that just returns plotting data #1097

Open sethaxen opened 4 years ago

sethaxen commented 4 years ago

The general pattern I'm seeing in most (all?) plotting functions is:

  1. Read inputs, process, make plot kwargs dict.
  2. Modify plot kwargs dict for the current backend
  3. Plot and optionally show using the backend

If the output of Step 1 was accessible, then users could pass the data to some other plotting package (of course with the heavy work of implementing the same plotting routine for that package).

This could be useful e.g. for ArviZ.jl, where one could then implement plotting functions for Plots.jl, which itself supports many backends, or Makie.jl, which supports interaction.

I see two main ways of doing it. First, one could have a backend like "data" that just returns the kwargs. Alternatively, the code to generate the kwargs could be refactored into its own function that the plotting function just wraps.

ahartikainen commented 4 years ago

It is doable. Our backend args are wild, really wild

sethaxen commented 4 years ago

Yeah, from a brief survey, it doesn't look like a difficult refactor; but the implementation of the plotting logic for e.g. Plots.jl using those arguments is quite a daunting task, and I don't think I'll be able to devote the time to it just yet, so I'd call this low priority for now.

OriolAbril commented 5 months ago

https://github.com/arviz-devs/arviz-plots/pull/41 will add this to arviz-plots (which also as part of the refactoring has both matplotlib and bokeh as optional dependencies)

I am also adding the nofix label here to indicate no work on this issue will happen within this repo.