Skip to content

Commit

Permalink
Fix layers 3 & above overlapping the axis lines
Browse files Browse the repository at this point in the history
fixes #798
  • Loading branch information
has2k1 committed Jun 14, 2024
1 parent 8a4881a commit c3678ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ title: Changelog
- [](:class:`~plotnine.geom_text`) has gained new aesthetics
`fontvariant` and `fontstretch`.

### Bug Fixes

- Fix layers 3 and above not to overlap the axis lines if there are any
({{< issue 798 >}}).

## v0.13.6
(2024-05-09)
Expand Down
14 changes: 12 additions & 2 deletions plotnine/themes/themeable.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,13 @@ class axis_line_x(themeable):

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

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

def apply_ax(self, ax: Axes):
super().apply_ax(ax)
properties = self.properties
# MPL has a default zorder of 2.5 for spines
# so layers 3+ would be drawn on top of the spines
if "zorder" not in properties:
properties["zorder"] = 10000
ax.spines["right"].set_visible(False)
ax.spines["left"].set(**self.properties)
ax.spines["left"].set(**properties)

def blank_ax(self, ax: Axes):
super().blank_ax(ax)
Expand Down

0 comments on commit c3678ec

Please sign in to comment.