Skip to content

Commit 324636c

Browse files
committed
Fix layers 3 & above overlapping the axis lines
fixes #798
1 parent 8a4881a commit 324636c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

doc/changelog.qmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ title: Changelog
1515
- [](:class:`~plotnine.geom_text`) has gained new aesthetics
1616
`fontvariant` and `fontstretch`.
1717

18+
### Bug Fixes
19+
20+
- Fix layers 3 and above not to overlap the axis lines if there are any
21+
({{< issue 798 >}}).
1822

1923
## v0.13.6
2024
(2024-05-09)

plotnine/themes/themeable.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,13 @@ class axis_line_x(themeable):
893893

894894
def apply_ax(self, ax: Axes):
895895
super().apply_ax(ax)
896+
properties = self.properties
897+
# MPL has a default zorder of 2.5 for spines
898+
# so layers 3+ would be drawn on top of the spines
899+
if "zorder" not in properties:
900+
properties["zorder"] = 10000
896901
ax.spines["top"].set_visible(False)
897-
ax.spines["bottom"].set(**self.properties)
902+
ax.spines["bottom"].set(**properties)
898903

899904
def blank_ax(self, ax: Axes):
900905
super().blank_ax(ax)
@@ -916,8 +921,13 @@ class axis_line_y(themeable):
916921

917922
def apply_ax(self, ax: Axes):
918923
super().apply_ax(ax)
924+
properties = self.properties
925+
# MPL has a default zorder of 2.5 for spines
926+
# so layers 3+ would be drawn on top of the spines
927+
if "zorder" not in properties:
928+
properties["zorder"] = 10000
919929
ax.spines["right"].set_visible(False)
920-
ax.spines["left"].set(**self.properties)
930+
ax.spines["left"].set(**properties)
921931

922932
def blank_ax(self, ax: Axes):
923933
super().blank_ax(ax)

0 commit comments

Comments
 (0)