Skip to content

Fix zorder handling for OffsetBoxes and subclasses. #19789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,12 @@ class OffsetBox(martist.Artist):
Being an artist itself, all parameters are passed on to `.Artist`.
"""
def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)

# Clipping has not been implemented in the OffesetBox family, so
super().__init__(*args)
self.update(kwargs)
# Clipping has not been implemented in the OffsetBox family, so
# disable the clip flag for consistency. It can always be turned back
# on to zero effect.
self.set_clip_on(False)

self._children = []
self._offset = (0, 0)

Expand Down
8 changes: 6 additions & 2 deletions lib/matplotlib/tests/test_offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from matplotlib.backend_bases import MouseButton

from matplotlib.offsetbox import (
AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea,
OffsetImage, TextArea, _get_packed_offsets)
AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea, OffsetBox,
OffsetImage, TextArea, _get_packed_offsets)


@image_comparison(['offsetbox_clipping'], remove_text=True)
Expand Down Expand Up @@ -321,3 +321,7 @@ def test_annotationbbox_extents():
fig.canvas.draw()
fig.tight_layout()
fig.canvas.draw()


def test_zorder():
assert OffsetBox(zorder=42).zorder == 42