Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First commit for violinplot #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

imperorrp
Copy link
Collaborator

@imperorrp imperorrp commented Aug 29, 2024

First commit for violinplot ( #14 )

plot_violin computes kde marginal densities like plot_dist does and then flips the 'x' and 'y' values to generate the characteristic violin-shape.

  • Separate artists have been defined for 'left' and 'right' densities and thus can be customized aesthetically or switched on/off with relevant plot_kwargs. In addition, I've also computed them separately so that this computation can also be customized through stats_kwargs, through things like bandwidth and others.

  • The line_xy visual element was modified with a new keyword arg 'negative' that makes either the sel(plot_axis='x') or sel(plot_axis='y') dataarrays negative

  • New visual elements were added for line_y and scatter_y which are pretty much symmetrical to line_x and scatter_x but for the other axis.

  • The 'y' aesthetic mapping applied to the credible interval, point estimate and point estimate text in plot_dist was converted to an 'x' aesthetic in case of multiple models- this needs refinement though (Maybe a mapping akin to the one in the ESS Plot PR Add ESS Plot #58 )

  • The remove_axis is now applied to the 'x' axis and a modification was required in the matplotlib backend for remove_axis for this

Possible improvement: having a separate 'face' and 'edge' artist for the left and right densities, like plot_ridge. This will require creating a symmetrical visual element for fill_between_x like fill_between_y.


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

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 9.18367% with 178 lines in your changes missing coverage. Please review.

Project coverage is 78.97%. Comparing base (f4a39af) to head (6a8be2e).

Files with missing lines Patch % Lines
src/arviz_plots/plots/violinplot.py 6.39% 161 Missing ⚠️
src/arviz_plots/visuals/__init__.py 23.80% 16 Missing ⚠️
src/arviz_plots/backend/matplotlib/__init__.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #85      +/-   ##
==========================================
- Coverage   84.80%   78.97%   -5.84%     
==========================================
  Files          21       22       +1     
  Lines        2336     2530     +194     
==========================================
+ Hits         1981     1998      +17     
- Misses        355      532     +177     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@imperorrp
Copy link
Collaborator Author

Current plot outputs:

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

azp.plot_violin({"centered": data, "non centered": data2}, var_names=["mu", "tau"])
image

azp.plot_violin(data)
image

@imperorrp imperorrp mentioned this pull request Sep 2, 2024
@imperorrp
Copy link
Collaborator Author

Added an error check preventing more than 2 models from being passed. I've tried to subselect the two models for the left and right violin densities, but it seems like two colors are still being passed over to the backends for the line visual element by pc.map, one for each of the models if they were overlapped instead. This has to be fixed somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants