Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e694393

Browse files
committed
deprecate boxplot:vertical rcparam
1 parent 07b29f7 commit e694393

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
``boxplot`` and ``bxp`` *vert* parameter
2-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1+
``boxplot`` and ``bxp`` *vert* parameter, and ``rcParams["boxplot.vertical"]``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

44
The parameter *vert: bool* has been deprecated on `~.Axes.boxplot` and
5-
`~.Axes.bxp`.
6-
It is replaced by *orientation: {"vertical", "horizontal"}* for API
7-
consistency.
5+
`~.Axes.bxp`. It is replaced by *orientation: {"vertical", "horizontal"}*
6+
for API consistency.
7+
8+
``rcParams["boxplot.vertical"]``, which controlled the orientation of ``boxplot``,
9+
is deprecated without replacement.

lib/matplotlib/axes/_axes.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4060,6 +4060,8 @@ def boxplot(self, x, notch=None, sym=None, vert=None,
40604060
labels=tick_labels, autorange=autorange)
40614061
if notch is None:
40624062
notch = mpl.rcParams['boxplot.notch']
4063+
if vert is None:
4064+
vert = mpl.rcParams['boxplot.vertical']
40634065
if patch_artist is None:
40644066
patch_artist = mpl.rcParams['boxplot.patchartist']
40654067
if meanline is None:
@@ -4359,17 +4361,23 @@ def merge_kw_rc(subkey, explicit, zdelta=0, usemarker=True):
43594361
mean_kw[removed_prop] = ''
43604362

43614363
# vert and orientation parameters are linked until vert's
4362-
# deprecation period expires. If both are selected,
4363-
# vert takes precedence.
4364-
if vert is not None:
4364+
# deprecation period expires. vert only takes precedence and
4365+
# raises a deprecation warning if set to False.
4366+
if vert is False:
43654367
_api.warn_deprecated(
43664368
"3.10",
43674369
name="vert: bool",
43684370
alternative="orientation: {'vertical', 'horizontal'}"
43694371
)
4370-
orientation = 'vertical' if vert else 'horizontal'
4372+
orientation = 'horizontal'
43714373
_api.check_in_list(['horizontal', 'vertical'], orientation=orientation)
43724374

4375+
if not mpl.rcParams['boxplot.vertical']:
4376+
_api.warn_deprecated(
4377+
"3.10",
4378+
name='boxplot.vertical', obj_type="rcparam"
4379+
)
4380+
43734381
# vertical or horizontal plot?
43744382
maybe_swap = slice(None) if orientation == 'vertical' else slice(None, None, -1)
43754383

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ boxplot.showbox: True
380380
boxplot.showcaps: True
381381
boxplot.showfliers: True
382382
boxplot.showmeans: False
383-
boxplot.vertical: True
384383
boxplot.whiskerprops.color: b
385384
boxplot.whiskerprops.linestyle: --
386385
boxplot.whiskerprops.linewidth: 1.0

lib/matplotlib/tests/test_axes.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9061,13 +9061,15 @@ def test_boxplot_orientation(fig_test, fig_ref):
90619061

90629062
plt.close()
90639063

9064-
# Deprecation of `vert: bool` keyword
9064+
# Deprecation of `vert: bool` keyword and
9065+
# 'boxplot.vertical' rcparam.
90659066
with pytest.warns(mpl.MatplotlibDeprecationWarning,
9066-
match='vert: bool was deprecated in Matplotlib 3.10'):
9067+
match='was deprecated in Matplotlib 3.10'):
90679068
# Compare images between a figure that
90689069
# uses vert and one that uses orientation.
9069-
ax_ref = fig_ref.subplots()
9070-
ax_ref.boxplot(all_data, vert=False)
9070+
with mpl.rc_context({'boxplot.vertical': False}):
9071+
ax_ref = fig_ref.subplots()
9072+
ax_ref.boxplot(all_data)
90719073

90729074
ax_test = fig_test.subplots()
90739075
ax_test.boxplot(all_data, orientation='horizontal')

0 commit comments

Comments
 (0)