From d9f7bb00c8a2d3b11d32e89dfc650f250e5a6f61 Mon Sep 17 00:00:00 2001 From: Sjoerd Stendahl Date: Sat, 30 Dec 2023 16:56:18 +0100 Subject: [PATCH 1/2] Only draw minor ticks if spine visible --- src/canvas.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/canvas.py b/src/canvas.py index aef2ac9b7..abee7065c 100644 --- a/src/canvas.py +++ b/src/canvas.py @@ -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 @@ -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() From 12f824f1bf7e580ae9260303d23fb2eda3d094f8 Mon Sep 17 00:00:00 2001 From: Sjoerd Stendahl Date: Sat, 30 Dec 2023 19:34:38 +0100 Subject: [PATCH 2/2] Don't edit x-y value if unused --- src/canvas.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/canvas.py b/src/canvas.py index abee7065c..a4e629171 100644 --- a/src/canvas.py +++ b/src/canvas.py @@ -162,12 +162,12 @@ def _on_pan_gesture(self, event_controller, x, y): Determines what to do when a panning gesture is detected, pans the canvas in the gesture direction. """ - if self.get_application().get_shift(): - x, y = y, x - if event_controller.get_unit() == Gdk.ScrollUnit.WHEEL: - x *= 10 - y *= 10 if self.get_application().get_ctrl() is False: + if self.get_application().get_shift(): + x, y = y, x + if event_controller.get_unit() == Gdk.ScrollUnit.WHEEL: + x *= 10 + y *= 10 for ax in self.axes: xmin, xmax, ymin, ymax = \ self._calculate_pan_values(ax, x, y)