arviz-devs / arviz-plots

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

Add plotly backend and gallery prototype #61

Closed OriolAbril closed 1 month ago

OriolAbril commented 2 months ago

📚 Documentation preview 📚: https://arviz-plots--61.org.readthedocs.build/en/61/

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 82.56228% with 49 lines in your changes missing coverage. Please review.

Project coverage is 85.14%. Comparing base (1298e42) to head (f90dd65). Report is 1 commits behind head on main.

Files Patch % Lines
src/arviz_plots/backend/plotly/__init__.py 85.84% 30 Missing :warning:
src/arviz_plots/style.py 9.09% 10 Missing :warning:
src/arviz_plots/backend/bokeh/__init__.py 50.00% 7 Missing :warning:
src/arviz_plots/__init__.py 81.81% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #61 +/- ## ========================================== - Coverage 85.85% 85.14% -0.72% ========================================== Files 17 20 +3 Lines 1951 2194 +243 ========================================== + Hits 1675 1868 +193 - Misses 276 326 +50 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

OriolAbril commented 1 month ago

I have added a simpler gallery_generator extension. I would like to change how things are documented a bit, having less examples in the docstring (not no examples though, but mostly examples that complement the docstring) and links from the docstrings to all example gallery pages that use it (where all backends will be shown instead of only matplotlib).

Consequently, instead of the python script with a docstring at its top, I think it will be easier to have two files with the same name one python the other markdown. We could go back to single py file with docstring, but I would "simplify" things and have the docstring be valid markdown/myst and added as is to the page for rendering.

OriolAbril commented 1 month ago

Ready to merge! 🎉

I am quite happy with the example gallery. It has a lot of common elements with the original one: cool css thanks to Sarina, tabs for different backends, link to api docs and to download the script. And in addition it has several improvements:

Regarding plotly, all currenly implemented plots already work, and I have also added initial support for the arviz-clean style. Now az.style.use in no longer an alias to matplotlib plt.style.use but instead sets that style as the default for all installed backends with style/template support. This still needs to be documented though.

aloctavodia commented 1 month ago

This is really awesome, so I am merging. I have a few nitpicks, that I am listing here. I can open issues later.

Marginal distribution comparison plot --- point-estimate overlaps (plotly okish, but not matplotlib), titles overlaps (plotly) ECDF plot --- plotly each variable has a different color, but the same for matplotlib and bokeh Trace and distribution plot -- plotly looks very tall compared to matplotlib Trace plot -- plotly titles overlap My first impression is that we should extend style.py so we have some of the functionalities available in matplotlib, at least being able to list the available styles.

OriolAbril commented 1 month ago

Issues will be great. Some of them will be fixed by #67 I think (as once implemented all backends should get roughly the same size, and definitely the same aspect ratio).

The title overlap is most probably bad plotly usage on my side 😅, and the different colors already have an open issue https://github.com/arviz-devs/arviz-plots/issues/56 as this is also an issue in matplotlib when we use plot dist to overlay things on the same plot (automatic cycling works differently in the backends: matplotlib cycles automatically within axes, bokeh does no automatic cycling and plotly cycles automatically within figures)