Skip to content

Commit

Permalink
Only draw minor ticks if spine visible
Browse files Browse the repository at this point in the history
  • Loading branch information
sstendahl committed Dec 30, 2023
1 parent b01e1e4 commit d9f7bb0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@ def _redraw(self, *_args):
visible_axes[2 + yposition] = True
used_axes[xposition + 2 * yposition] = True
axes_directions = (
("bottom", "left"), # axis
("left", "bottom"), # axis
("top", "left"), # top_left_axis
("bottom", "right"), # right_axis
("top", "right"), # top_right_axis
("right", "top"), # top_right_axis
)
axes_ticks = ("ytick.left", "xtick.top", "xtick.bottom", "ytick.right")

if not any(visible_axes):
visible_axes = (True, False, True, False) # Left and bottom
Expand All @@ -310,18 +311,19 @@ def _redraw(self, *_args):
draw_frame = params["axes.spines.bottom"]
ticks = "both" if params["xtick.minor.visible"] else "major"
possible_directions = ("bottom", "top", "left", "right")
for directions, axis, used \
in zip(axes_directions, self.axes, used_axes):
for directions, axis, used, axis_ticks \
in zip(axes_directions, self.axes, used_axes, axes_ticks):
axis.get_xaxis().set_visible(False)
axis.get_yaxis().set_visible(False)
# Set tick where requested, as long as that axis is not occupied
# and visible
axis.tick_params(which=ticks, **{
direction: (draw_frame and not visible_axes[i]
or direction in directions)
and params[f"{'x' if i < 2 else 'y'}tick.{direction}"]
for i, direction in enumerate(possible_directions)
})
if params[axis_ticks]:
axis.tick_params(which=ticks, **{
direction: (draw_frame and not visible_axes[i]
or direction in directions)
and params[f"{'x' if i < 2 else 'y'}tick.{direction}"]
for i, direction in enumerate(possible_directions)
})
for handle in axis.lines + axis.texts:
handle.remove()
axis_legend = axis.get_legend()
Expand Down

0 comments on commit d9f7bb0

Please sign in to comment.