-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add orientation
parameter to Boxplot and deprecate vert
#28074
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
Conversation
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.
Will only leave comments for now, but in general looks OK once the tests are passing.
- Replace
vert
withorientation
in the failing tests (you have added a similarity test for the transition period, so makes sense to update the old ones) - Not sure how the discussion w.r.t. the rcParam went, but I think it makes sense to deprecate that as well. Not sure what the path is there though...
boxplot.vertical
That test is passing on my end, I don't know what the problem is 🤔 |
Looks like the test just timed out. Let’s see if a re-spin helps… Edit: apparently not. |
|
bdcfc97
to
3bc3735
Compare
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.
Modulo two documentation suggestions.
Thanks @saranti!
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.
Thanks @saranti, this is looking great!
It took me a while to get my head around why we are not warning when vert=True
is explicitly passed. I guess it's because it's too complicated to do for bxp
as we can't tell whether it came from the rcParam. However would it be worth adding an extra warning in boxplot
specifically for when vert=True
? Apologies if I've missed some discussion on this somewhere.
lib/matplotlib/tests/test_axes.py
Outdated
@@ -3155,7 +3155,7 @@ def _bxp_test_helper( | |||
logstats = mpl.cbook.boxplot_stats( | |||
np.random.lognormal(mean=1.25, sigma=1., size=(37, 4)), **stats_kwargs) | |||
fig, ax = plt.subplots() | |||
if bxp_kwargs.get('vert', True): | |||
if not bxp_kwargs.get('orientation') or bxp_kwargs.get('orientation') == 'vertical': |
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.
if not bxp_kwargs.get('orientation') or bxp_kwargs.get('orientation') == 'vertical': | |
if bxp_kwargs.get('orientation', 'vertical') == 'vertical': |
Defines a default and so avoids calling get
twice.
Good catch. Since we have the tri-state True/False/None, we can detect whenever True/False was passed explicitly. If we push rcParams resolution down to |
That would mean the rcParam affects cases where the user calls |
Could we also set the rcParam in the default matplotlibrc to matplotlib/lib/matplotlib/__init__.py Line 646 in 46b39ab
If I have understood, that would mean we get the warning if the rcParam is explicitly set to either |
Indeed. But it would only affect Re rcParam None: I have not been able / spent enough time to fully understand the mechanics (see #28074 (comment)) but the solution there to warn on rcParam readout seems good enough. We only don't warn if you configure the rcParam explicitly to True (but why would one do that when it's the default behavior anyway). |
I didn't see any reason why the |
ca45848
to
0f7a522
Compare
PR summary
Closes #13435 together with PR #27998.
Replace the vert: bool parameter with orientation : {'vertical', 'horizontal'}. Changes are very similar to the work done on #27998 and most of it works interchangeably.
PR checklist