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 ~~~~~~~~~~~~ diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index 85bba9d..eb0fea2 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -115,7 +115,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() diff --git a/src/napari_matplotlib/tests/test_histogram.py b/src/napari_matplotlib/tests/test_histogram.py index 435973b..f6ad8a1 100644 --- a/src/napari_matplotlib/tests/test_histogram.py +++ b/src/napari_matplotlib/tests/test_histogram.py @@ -152,3 +152,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]