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

Skip to content

Commit 0af446b

Browse files
committed
default zorder for clabel changed to (2+zorder of contour/contourf)
1 parent 9922b0f commit 0af446b

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
Set zorder of contour labels
22
----------------------------
33
`~.axes.Axes.clabel` now accepts a ``zorder`` kwarg
4-
making it easier to set the ``zorder`` of contour labels.
4+
making it easier to set the ``zorder`` of contour labels.
5+
If not specified, the default ``zorder`` of clabels used to always be 3
6+
(i.e. the default ``zorder`` of `~.text.Text`) irrespective of the ``zorder``
7+
passed to `~.axes.Axes.contour`/`~.axes.Axes.contourf`.
8+
The new default ``zorder`` for clabels has been changed to (2 + ``zorder``
9+
passed to `~.axes.Axes.contour`/`~.axes.Axes.contourf`).

lib/matplotlib/contour.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ def clabel(self, levels=None, *,
127127
zorder : float or None, optional
128128
zorder of the contour labels.
129129
130-
If not specified, the zorder of contour labels is set to either
131-
(2 + zorder of contours) or (1 + zorder of contours) depending on
132-
whether the contours are filled or not filled.
130+
If not specified, the zorder of contour labels is set to
131+
(2 + zorder of contours).
133132
134133
Returns
135134
-------
@@ -152,10 +151,7 @@ def clabel(self, levels=None, *,
152151
self.labelManual = manual
153152
self.rightside_up = rightside_up
154153
if zorder is None:
155-
if self.filled:
156-
self._clabel_zorder = 2+self._contour_zorder
157-
else:
158-
self._clabel_zorder = 1+self._contour_zorder
154+
self._clabel_zorder = 2+self._contour_zorder
159155
else:
160156
self._clabel_zorder = zorder
161157

lib/matplotlib/tests/test_contour.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,14 @@ def test_clabel_zorder(use_clabeltext, contour_zorder, clabel_zorder):
305305
use_clabeltext=use_clabeltext)
306306

307307
if clabel_zorder is None:
308-
expected_clabel_zorder = 1+contour_zorder
309-
expected_filled_clabel_zorder = 2+contour_zorder
308+
expected_clabel_zorder = 2+contour_zorder
310309
else:
311310
expected_clabel_zorder = clabel_zorder
312-
expected_filled_clabel_zorder = clabel_zorder
313311

314312
for clabel in clabels1:
315313
assert clabel.get_zorder() == expected_clabel_zorder
316314
for clabel in clabels2:
317-
assert clabel.get_zorder() == expected_filled_clabel_zorder
315+
assert clabel.get_zorder() == expected_clabel_zorder
318316

319317

320318
@image_comparison(['contour_log_extension.png'],

0 commit comments

Comments
 (0)