From 382107ef8657272ca863339d223e380a3b303c40 Mon Sep 17 00:00:00 2001 From: Neil Vaytet Date: Fri, 8 Mar 2024 13:38:42 +0100 Subject: [PATCH] fix hover on 1d figures --- src/plopp/backends/matplotlib/canvas.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plopp/backends/matplotlib/canvas.py b/src/plopp/backends/matplotlib/canvas.py index 026cbab9..ffa9027a 100644 --- a/src/plopp/backends/matplotlib/canvas.py +++ b/src/plopp/backends/matplotlib/canvas.py @@ -309,13 +309,19 @@ def format_coord(self, x: float, y: float) -> str: xstr = _cursor_formatter(x, self.dtypes['x'], self.units['x']) ystr = _cursor_formatter(y, self.dtypes['y'], self.units['y']) out = f"({self._cursor_x_prefix}{xstr}, {self._cursor_y_prefix}{ystr})" + if not self._coord_formatters: + return out xpos = ( self.dims['x'], _cursor_value_to_variable(x, self.dtypes['x'], self.units['x']), ) ypos = ( - self.dims['y'], - _cursor_value_to_variable(y, self.dtypes['y'], self.units['y']), + ( + self.dims['y'], + _cursor_value_to_variable(y, self.dtypes['y'], self.units['y']), + ) + if 'y' in self.dims + else None ) extra = [formatter(xpos, ypos) for formatter in self._coord_formatters] extra = [e for e in extra if e is not None]