Skip to content

Commit 53dce94

Browse files
committed
Fix zorder handling for OffsetBoxes and subclasses.
`kwargs` need to be handled separately via `Artist.update`. This pattern is consistent with other artist subclasses (Line2D, _ImageBase, Text, etc.).
1 parent 06dc612 commit 53dce94

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,12 @@ class OffsetBox(martist.Artist):
192192
Being an artist itself, all parameters are passed on to `.Artist`.
193193
"""
194194
def __init__(self, *args, **kwargs):
195-
196-
super().__init__(*args, **kwargs)
197-
195+
super().__init__(*args)
196+
self.update(kwargs)
198197
# Clipping has not been implemented in the OffesetBox family, so
199198
# disable the clip flag for consistency. It can always be turned back
200199
# on to zero effect.
201200
self.set_clip_on(False)
202-
203201
self._children = []
204202
self._offset = (0, 0)
205203

lib/matplotlib/tests/test_offsetbox.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from matplotlib.backend_bases import MouseButton
1313

1414
from matplotlib.offsetbox import (
15-
AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea,
16-
OffsetImage, TextArea, _get_packed_offsets)
15+
AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea, OffsetBox,
16+
OffsetImage, TextArea, _get_packed_offsets)
1717

1818

1919
@image_comparison(['offsetbox_clipping'], remove_text=True)
@@ -321,3 +321,7 @@ def test_annotationbbox_extents():
321321
fig.canvas.draw()
322322
fig.tight_layout()
323323
fig.canvas.draw()
324+
325+
326+
def test_zorder():
327+
assert OffsetBox(zorder=42).zorder == 42

0 commit comments

Comments
 (0)