Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Add a neworientation parameter to Violinplot and deprecatevert#27998
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/axes/_axes.py Outdated
| defviolinplot(self,dataset,positions=None,vert=None, | ||
| orientation='vertical',widths=0.5,showmeans=False, | ||
| showextrema=True,showmedians=False, | ||
| quantiles=None,points=100,bw_method=None,side='both'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
orientation can't be inserted in the middle here to prevent breaking passing all arguments positionally. I believe that will be fixed by#27786.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Since#27786 is now merged, should we putorientation in the place wherevert was?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
timhoffm commentedApr 2, 2024
It would also be nice to make this a pending deprecation at first. Otherwise users of downstream libraries like seaborn (attn@mwaskom) will see our deprecation warning, but cannot do anything about it because it's in the seaborn code base. During the pending period, downstream libraries can already switch to the new API. |
mwaskom commentedApr 3, 2024
Thoughtful but no need specifically for seaborn — seaborn's violinplots predate matplotlib's by several years :D |
timhoffm commentedApr 3, 2024
Thanks for the feedback. I’ve only checked boxplot, which will get the same change (#13435). |
mwaskom commentedApr 3, 2024
Oh actually boxplot is relevant to me. But I don’t think this is right:
The |
saranti commentedApr 5, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Edit: This block of code is going to be copied verbatim for the boxplots. Would it be better to turn it into a function and add it to _axes.py or cbook? matplotlib/lib/matplotlib/axes/_axes.py Lines 8553 to 8566 in78ac503
|
lib/matplotlib/axes/_axes.py Outdated
| # vert and orientation parameters are linked until vert's | ||
| # deprecation period expires. If both are selected, | ||
| # vert takes precedence. | ||
| ifvertorvertisNoneandorientationisNone: | ||
| orientation='vertical' | ||
| elifvertisFalse: | ||
| orientation='horizontal' | ||
| iforientationisnotNone: | ||
| _api.check_in_list(['horizontal','vertical'],orientation=orientation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm not following the logic here completely. After whatever mangling vert and orientation, shouldn't we have a normalizedorientation that must be 'horizontal' or 'vertical'? In other words
- Why do we allow orientation to be None in 8617 and would that even work for the following code?
Can't we simply
if vert is not None: _api.warn_deprecated(...) orientation = 'vertical' if vert else 'horizontal'_api.check_in_list(['horizontal', 'vertical'], orientation=orientation)and defaultorientation='vertical' instead of defaulting it to None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes it should default to vertical instead of None (it even says so in the docstring) so there was no reason for it other than making it more convoluted. That code change is great, I'll add it to the next commit
rcomer left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This seems much simpler than theboxplot one!
This block of code is going to be copied verbatim for the boxplots. Would it be better to turn it into a function and add it to _axes.py or cbook?
It's only needed during the deprecation period. Once it's over, the whole thing will be removed.
This is a good point. I think my inclination is to leave it duplicated in the two functions. It's pretty simple (more simple now than when you asked the question!) so I don't think the duplication does much harm.
lib/matplotlib/axes/_axes.py Outdated
| The positions of the violins; i.e. coordinates on the x-axis for | ||
| vertical violins (or y-axis for horizontal violins). | ||
| vert : bool, default: True. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| vert :bool,default:True. | |
| vert :bool,optional |
(optional is synonymous withdefault: None)
Uh oh!
There was an error while loading.Please reload this page.
PR summary
Partiallycloses#13435. Replace the
vert: boolparameter withorientation : {'vertical', 'horizontal'}.Also changed the Violin plot basics gallery example to reflect the changes.
The other half of issue#13435 is to do the same to boxplots
PR checklist