Skip to content

Commit 223e1f0

Browse files
committed
Fix autoscaling logic in BaseCrossSectionPlot: streamline handling of autoscale and lockscales, ensuring consistent scaling behavior across methods.
1 parent 757c6fa commit 223e1f0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171

7272
🛠️ Bug fixes:
7373

74+
* Cross-section panels: Fixed autoscaling logic in `BaseCrossSectionPlot`
75+
* Streamlined handling of `autoscale_mode` and `lockscales` options for consistent scaling behavior across all code paths
76+
* The `update_plot()` method now delegates all scaling logic to `plot_axis_changed()` to avoid code duplication and ensure consistency
77+
* Fixed issue where Y cross-section plots for rectangular images with non-uniform axes (e.g., Y = f(X)) were not properly scaled on initial display
78+
* The lockscales mode now correctly syncs the cross-section axis (CS_AXIS) to the image plot while autoscaling the intensity axis (Z_AXIS)
7479
* [Issue #49](https://github.com/PlotPyStack/PlotPy/issues/49) - Fixed multiple coordinate handling bugs in `XYImageItem`:
7580
* **Root cause**: `XYImageItem` internally stores bin edges (length n+1) but several methods were incorrectly treating them as pixel centers (length n)
7681
* Fixed `get_x_values()` and `get_y_values()` to correctly compute and return pixel centers from stored bin edges: `(edge[i] + edge[i+1]) / 2`

plotpy/panels/csection/csplot.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ def plot_axis_changed(self, plot: BasePlot) -> None:
227227
Args:
228228
plot: Plot containing the image items to be used for cross section
229229
"""
230-
if self.lockscales:
230+
if self.autoscale_mode:
231+
self.do_autoscale(replot=True)
232+
elif self.lockscales:
231233
self.do_autoscale(replot=False, axis_id=self.Z_AXIS)
232234
vmin, vmax = plot.get_axis_limits(self.CS_AXIS)
233235
self.set_axis_limits(self.CS_AXIS, vmin, vmax)
@@ -278,7 +280,8 @@ def update_plot(self, obj: Any = None, refresh: bool = True) -> None:
278280
return
279281
else:
280282
self.last_obj = weakref.ref(obj)
281-
if obj.plot() is None:
283+
plot = obj.plot()
284+
if plot is None:
282285
self.unregister_shape(obj)
283286
return
284287
if self.label.isVisible():
@@ -294,10 +297,9 @@ def update_plot(self, obj: Any = None, refresh: bool = True) -> None:
294297
curve.apply_lut = self.apply_lut
295298
if refresh:
296299
curve.update_item(obj)
297-
if self.autoscale_mode:
298-
self.do_autoscale(replot=True)
299-
elif self.lockscales:
300-
self.do_autoscale(replot=True, axis_id=self.Z_AXIS)
300+
301+
# Delegate all scaling logic to plot_axis_changed for consistency
302+
self.plot_axis_changed(plot)
301303

302304
def toggle_perimage_mode(self, state: bool) -> None:
303305
"""Toggle the per item mode

0 commit comments

Comments
 (0)