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

Skip to content

Commit 4c3cc9d

Browse files
committed
Deprecate parameter orientation of bar() and barh()
1 parent d541b6d commit 4c3cc9d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ experimental and may change in the future.
531531
These are unused and can be easily reproduced by other date tools.
532532
`.get_epoch` will return Matplotlib's epoch.
533533

534+
Passing ``orientation`` to ``bar()`` and ``barh()``
535+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
536+
This parameter is considered internal. Please use ``bar()`` for vertical bars
537+
and ``barh()`` for horizontal bars.
538+
534539
``axes_grid1.CbarAxes`` attributes
535540
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
536541
The ``cbid`` and ``locator`` attribute are deprecated. Use

lib/matplotlib/axes/_axes.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,14 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
23922392
error_kw.setdefault('ecolor', ecolor)
23932393
error_kw.setdefault('capsize', capsize)
23942394

2395-
orientation = kwargs.pop('orientation', 'vertical')
2395+
if 'orientation' in kwargs:
2396+
orientation = kwargs['orientation']
2397+
cbook.warn_deprecated(
2398+
"3.3", message="passing 'orientation' to bar() is for "
2399+
"internal use only. Please use barh() or bar() "
2400+
"explicitly to define the orientation.")
2401+
else:
2402+
orientation = kwargs.pop('_orientation', 'vertical')
23962403
cbook._check_in_list(['vertical', 'horizontal'],
23972404
orientation=orientation)
23982405
log = kwargs.pop('log', False)
@@ -2630,9 +2637,17 @@ def barh(self, y, width, height=0.8, left=None, *, align="center",
26302637
:doc:`/gallery/lines_bars_and_markers/horizontal_barchart_distribution`
26312638
.
26322639
"""
2633-
kwargs.setdefault('orientation', 'horizontal')
2640+
2641+
if 'orientation' in kwargs:
2642+
orientation = kwargs['orientation']
2643+
cbook.warn_deprecated(
2644+
"3.3", message="passing 'orientation' to barh() is for "
2645+
"internal use only. Please use bar() or barh() "
2646+
"explicitly to define the orientation.")
2647+
else:
2648+
orientation = 'horizontal'
26342649
patches = self.bar(x=left, height=height, width=width, bottom=y,
2635-
align=align, **kwargs)
2650+
align=align, _orientation=orientation, **kwargs)
26362651
return patches
26372652

26382653
@_preprocess_data()

0 commit comments

Comments
 (0)