arviz-devs / arviz-plots

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

Abstract common tasks between plot_forest and plot_ridge #69

Open OriolAbril opened 4 months ago

OriolAbril commented 4 months ago

Both functions have significant portions of code that are common, they should be abstracted into a single source to reduce duplication.

Extra comment/bit of a side note: One part where they do differ is that plot_forest generates colmun=[labes, forest] and plot_ridge generates column=[labels, ridge]. This means that the following is not possible:

pc = plot_forest(data)
pc = plot_ridge(data, plot_collection=pc)

to generate a ridge plot with the point estimates and the credible intervals. As of now, it would be necessary to rename the coordinate values in pc.viz. Is that what we want?

imperorrp commented 4 months ago

If we rename the coordinates to a common pair we could maybe do column = [label, data] in lieu of "forest" and "ridge".

Otherwise as another solution (for the case you mention as an example) we could maybe check for the existence of either the "forest" or "ridge" coord if an existing pc is passed as a parameter to the function. Then based on the plotting function called, change it appropriately in the pc.viz. So we could just have to add a check to account for this case.