Skip to content

Commit 7c6fc2b

Browse files
authored
Merge branch 'main' into theme_detection_update
2 parents 5fd8418 + 1e21a93 commit 7c6fc2b

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

.github/workflows/docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- main
1111
tags:
1212
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
13+
workflow_dispatch:
1314

1415
jobs:
1516
build-docs:

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
- id: trailing-whitespace
88

99
- repo: https://github.com/psf/black
10-
rev: 23.11.0
10+
rev: 23.12.1
1111
hooks:
1212
- id: black
1313

@@ -17,14 +17,14 @@ repos:
1717
- id: napari-plugin-checks
1818

1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.7.1
20+
rev: v1.8.0
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [numpy, matplotlib]
2424

2525
- repo: https://github.com/astral-sh/ruff-pre-commit
2626
# Ruff version.
27-
rev: 'v0.1.6'
27+
rev: 'v0.1.11'
2828
hooks:
2929
- id: ruff
3030

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[metadata]
2-
name = napari_matplotlib
2+
name = napari-matplotlib
33
description = A plugin to use Matplotlib with napari
44
long_description = file: README.md
55
long_description_content_type = text/markdown

src/napari_matplotlib/histogram.py

+21
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ def __init__(
3030
):
3131
super().__init__(napari_viewer, parent=parent)
3232
self._update_layers(None)
33+
self.viewer.events.theme.connect(self._on_napari_theme_changed)
34+
35+
def on_update_layers(self) -> None:
36+
"""
37+
Called when the selected layers are updated.
38+
"""
39+
super().on_update_layers()
40+
for layer in self.viewer.layers:
41+
layer.events.contrast_limits.connect(self._update_contrast_lims)
42+
43+
def _update_contrast_lims(self) -> None:
44+
for lim, line in zip(
45+
self.layers[0].contrast_limits, self._contrast_lines
46+
):
47+
line.set_xdata(lim)
48+
49+
self.figure.canvas.draw()
3350

3451
def draw(self) -> None:
3552
"""
@@ -63,6 +80,10 @@ def draw(self) -> None:
6380
else:
6481
self.axes.hist(data.ravel(), bins=bins, label=layer.name)
6582

83+
self._contrast_lines = [
84+
self.axes.axvline(lim, color="white")
85+
for lim in layer.contrast_limits
86+
]
6687
self.axes.legend()
6788

6889

0 commit comments

Comments
 (0)