From 5fc4a645d28ae52794ec519940a8f00a440a0e0e Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 25 Sep 2025 09:22:37 +0100 Subject: [PATCH 1/3] Pass a list to line.set_xdata rather than a float --- src/napari_matplotlib/histogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index adbbae6..7518eaa 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -62,7 +62,7 @@ def _update_contrast_lims(self) -> None: for lim, line in zip( self.layers[0].contrast_limits, self._contrast_lines, strict=False ): - line.set_xdata(lim) + line.set_xdata([lim]) self.figure.canvas.draw() From 6a185230096f053000bdf18104aac652bfa0ae1e Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 25 Sep 2025 09:25:48 +0100 Subject: [PATCH 2/3] Add test for changing contrast limits with histogram open --- src/napari_matplotlib/tests/test_histogram.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/napari_matplotlib/tests/test_histogram.py b/src/napari_matplotlib/tests/test_histogram.py index 1ceca51..9a12c15 100644 --- a/src/napari_matplotlib/tests/test_histogram.py +++ b/src/napari_matplotlib/tests/test_histogram.py @@ -138,3 +138,15 @@ def test_change_layer(make_napari_viewer, brain_data, astronaut_data): viewer.layers.selection.clear() viewer.layers.selection.add(viewer.layers[1]) assert_figures_not_equal(widget.figure, fig1) + + +def test_change_contrast(make_napari_viewer, astronaut_data): + viewer = make_napari_viewer() + viewer.add_image(astronaut_data[0], **astronaut_data[1]) + + widget = HistogramWidget(viewer) + viewer.window.add_dock_widget(widget) + + # update contrast limits of image layer, and check no errors are thrown + image_layer = viewer.layers[0] + image_layer.contrast_limits = [2, 50] From 33f69d8410f21edf42797d52e42edeca1b64e153 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 25 Sep 2025 11:24:37 +0100 Subject: [PATCH 3/3] Update changelog --- docs/changelog.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 60dd72b..4cf1964 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,7 +1,13 @@ Changelog ========= -2.1.0 +3.0.1 +----- +Bug fixes +~~~~~~~~~ +- Fix an error that happened when changing the contrast limit when the histogram widget was open + +3.0.0 ----- New features ~~~~~~~~~~~~