arviz-devs / arviz-plots

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

Adding Plot ESS Evolution #71

Closed imperorrp closed 1 month ago

imperorrp commented 4 months ago

First commit for plot_ess_evolution(), as a branched off plot from legacy plot_ess for kind = 'evolution' (https://github.com/arviz-devs/arviz-plots/issues/5). The line_xy and scatter_xy visual elements were used for the plotting, with rug plot, axes labelling and title labelling functionality taken from ESS plot functionality. Since the ESS plot PR hasn't been merged yet, the scatter_xy visual element was duplicated for use here.

WIP:

Marking the 'bulk' and 'tail' artists with a legend

Current plot outputs:

azp.plot_ess_evolution(data) image

azp.plot_ess_evolution(data, var_names=["mu", "tau"]) image


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

codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 94.76440% with 10 lines in your changes missing coverage. Please review.

Project coverage is 86.47%. Comparing base (3cc46aa) to head (ea60c47). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/arviz_plots/plots/evolutionplot.py 94.73% 10 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #71 +/- ## ========================================== + Coverage 85.65% 86.47% +0.81% ========================================== Files 22 23 +1 Lines 2545 2736 +191 ========================================== + Hits 2180 2366 +186 - Misses 365 370 +5 ```

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

imperorrp commented 3 months ago

Updated plot_ess_evolution. The points and lines for both 'bulk' and 'tail' methods can now be turned on and off via plot_kwargs, the mean, sd, and min_ess were added following the current plot_ess logic, and xlabel and ylabel texts can also now be set separately.

Also added a common ess_dataset computing function since it can be called upto 4 times (one for each of the cartesian product of 'bulk', 'tail' and points, lines).

The rug plot element is still WIP.

The outputs without the rug are now like: image

image

image

An aesthetics issue with the color coding of the mean/sd plot elements:

For the mean/sd plotting (and this'd similarly apply to plot_ess too) it looks like setting mean and sd to one color by default as I'm doing currently makes it hard to interpret that they have been overlapped when they coincide: image

When they're not set to the same color, it's visible that they coincide and are overlapped but then the colors might be confusing as they correspond to the 'bulk' and 'tail' plotting elements' colors too: image

imperorrp commented 3 months ago

Rebased plot ess evolution commits

imperorrp commented 3 months ago

The mean and sd lines are now annotated:

image

Should the min_ess line also be annotated? (This also applies for ESS plot #58 ). Current Arviz ESS plot doesn't have it annotated (https://github.com/arviz-devs/arviz/blob/main/arviz/plots/backends/matplotlib/essplot.py#L150) but it would probably be nice to have and is easy to add.

imperorrp commented 2 months ago

Fixed hypothesis tests errors and documentation build