Skip to content

Commit e078f91

Browse files
committed
API: change signature of bar and barh
Change the documented first position argument to x and y for bar and barh respectively but still support passing in left and bottom as keyword arguments. closes #7954 closes #8327 closes #8527 closes #8882
1 parent 7cf904d commit e078f91

File tree

7 files changed

+241
-83
lines changed

7 files changed

+241
-83
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Change to signatures of :meth:`~matplotlib.axes.Axes.bar` & :meth:`~matplotlib.axes.Axes.barh`
2+
----------------------------------------------------------------------------------------------
3+
4+
For 2.0 the :ref:`default value of *align* <barbarh_align>` changed to
5+
``'center'``. However this caused the signature of
6+
:meth:`~matplotlib.axes.Axes.bar` and
7+
:meth:`~matplotlib.axes.Axes.barh` to be misleading as the first parameters were
8+
still *left* and *bottom* respectively::
9+
10+
bar(left, height, *, align='center', **kwargs)
11+
barh(bottom, width, *, align='center', **kwargs)
12+
13+
despite behaving as the center in both cases. The methods now take ``*args, **kwargs``
14+
is input and are documented to have the primary signatures of::
15+
16+
bar(x, height, *, align='center', **kwargs)
17+
barh(y, width, *, align='center', **kwargs)
18+
19+
Passing *left* and *bottom* as keyword arguments to
20+
:meth:`~matplotlib.axes.Axes.bar` and
21+
:meth:`~matplotlib.axes.Axes.barh` respectively will warn.
22+
Support will be removed in Matplotlib 3.0.

doc/users/dflt_style_changes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ The default value of the ``linecolor`` kwarg for `~matplotlib.Axes.hexbin` has
599599
changed from ``'none'`` to ``'face'``. If 'none' is now supplied, no line edges
600600
are drawn around the hexagons.
601601

602+
.. _barbarh_align:
603+
602604
``bar`` and ``barh``
603605
--------------------
604606

examples/pie_and_polar_charts/nested_pie.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
left_middle = np.arange(0.0, 2 * np.pi, 2 * np.pi / 12)
4545
left_outer = np.arange(0.0, 2 * np.pi, 2 * np.pi / 9)
4646

47-
ax.bar(left=left_inner,
47+
ax.bar(x=left_inner,
4848
width=2 * np.pi / 6, bottom=0, color='C0',
4949
linewidth=2, edgecolor='w',
5050
height=np.zeros_like(left_inner) + 5)
5151

52-
ax.bar(left=left_middle,
52+
ax.bar(x=left_middle,
5353
width=2 * np.pi / 12, bottom=5, color='C1',
5454
linewidth=2, edgecolor='w',
5555
height=np.zeros_like(left_middle) + 2)
5656

57-
ax.bar(left=left_outer,
57+
ax.bar(x=left_outer,
5858
width=2 * np.pi / 9, bottom=7, color='C2',
5959
linewidth=2, edgecolor='w',
6060
height=np.zeros_like(left_outer) + 3)

0 commit comments

Comments
 (0)