Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5586981

Browse filesBrowse files
authored
Merge branch 'main' into more-ruff
2 parents fe4a503 + e1d3c50 commit 5586981
Copy full SHA for 5586981

File tree

Expand file treeCollapse file tree

3 files changed

+29
-11
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+29
-11
lines changed

‎src/napari_matplotlib/base.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/base.py
+27-11Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pathlib import Path
33
from typing import List, Tuple
44

5-
import matplotlib as mpl
65
import napari
76
from matplotlib.backends.backend_qt5agg import (
87
FigureCanvas,
@@ -13,18 +12,10 @@
1312

1413
from .util import Interval
1514

16-
mpl.rc("axes", edgecolor="white")
17-
mpl.rc("axes", facecolor="#262930")
18-
mpl.rc("axes", labelcolor="white")
19-
mpl.rc("savefig", facecolor="#262930")
20-
mpl.rc("text", color="white")
21-
22-
mpl.rc("xtick", color="white")
23-
mpl.rc("ytick", color="white")
24-
2515
# Icons modified from
2616
# https://github.com/matplotlib/matplotlib/tree/main/lib/matplotlib/mpl-data/images
2717
ICON_ROOT = Path(__file__).parent / "icons"
18+
NAPARI_WINDOW_COLOR = "#262930"
2819
__all__ = ["NapariMPLWidget"]
2920

3021

@@ -57,8 +48,9 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
5748

5849
self.viewer = napari_viewer
5950
self.canvas = FigureCanvas()
51+
52+
self.canvas.figure.patch.set_facecolor(NAPARI_WINDOW_COLOR)
6053
self.canvas.figure.set_layout_engine("constrained")
61-
self.canvas.figure.patch.set_facecolor("#262930")
6254
self.toolbar = NapariNavigationToolbar(self.canvas, self)
6355
self._replace_toolbar_icons()
6456

@@ -133,6 +125,30 @@ def draw(self) -> None:
133125
This is a no-op, and is intended for derived classes to override.
134126
"""
135127

128+
def apply_napari_colorscheme(self):
129+
"""
130+
Apply napari-compatible colorscheme to the axes object.
131+
"""
132+
if self.axes is None:
133+
return
134+
# changing color of axes background to napari main window color
135+
self.canvas.figure.patch.set_facecolor(NAPARI_WINDOW_COLOR)
136+
137+
# changing color of plot background to napari main window color
138+
self.axes.set_facecolor(NAPARI_WINDOW_COLOR)
139+
140+
# changing colors of all axes
141+
[
142+
self.axes.spines[spine].set_color("white")
143+
for spine in self.axes.spines
144+
]
145+
self.axes.xaxis.label.set_color("white")
146+
self.axes.yaxis.label.set_color("white")
147+
148+
# changing colors of axes labels
149+
self.axes.tick_params(axis="x", colors="white")
150+
self.axes.tick_params(axis="y", colors="white")
151+
136152
def _on_update_layers(self) -> None:
137153
"""
138154
This function is called when self.layers is updated via

‎src/napari_matplotlib/histogram.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/histogram.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class HistogramWidget(NapariMPLWidget):
2222
def __init__(self, napari_viewer: napari.viewer.Viewer):
2323
super().__init__(napari_viewer)
2424
self.axes = self.canvas.figure.subplots()
25+
self.apply_napari_colorscheme()
2526
self.update_layers(None)
2627

2728
def clear(self) -> None:

‎src/napari_matplotlib/scatter.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/scatter.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
2828
super().__init__(napari_viewer)
2929

3030
self.axes = self.canvas.figure.subplots()
31+
self.apply_napari_colorscheme()
3132
self.update_layers(None)
3233

3334
def clear(self) -> None:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.