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

added colorsetting function #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions 38 src/napari_matplotlib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pathlib import Path
from typing import List, Tuple

import matplotlib as mpl
import napari
from matplotlib.backends.backend_qt5agg import (
FigureCanvas,
Expand All @@ -13,18 +12,10 @@

from .util import Interval

mpl.rc("axes", edgecolor="white")
mpl.rc("axes", facecolor="#262930")
mpl.rc("axes", labelcolor="white")
mpl.rc("savefig", facecolor="#262930")
mpl.rc("text", color="white")

mpl.rc("xtick", color="white")
mpl.rc("ytick", color="white")

# Icons modified from
# https://github.com/matplotlib/matplotlib/tree/main/lib/matplotlib/mpl-data/images
ICON_ROOT = Path(__file__).parent / "icons"
NAPARI_WINDOW_COLOR = "#262930"
__all__ = ["NapariMPLWidget"]


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

self.viewer = napari_viewer
self.canvas = FigureCanvas()

self.canvas.figure.patch.set_facecolor(NAPARI_WINDOW_COLOR)
self.canvas.figure.set_layout_engine("constrained")
self.canvas.figure.patch.set_facecolor("#262930")
self.toolbar = NapariNavigationToolbar(self.canvas, self)
self._replace_toolbar_icons()

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

def apply_napari_colorscheme(self):
"""
Apply napari-compatible colorscheme to the axes object.
"""
if self.axes is None:
return
# changing color of axes background to napari main window color
self.canvas.figure.patch.set_facecolor(NAPARI_WINDOW_COLOR)

# changing color of plot background to napari main window color
self.axes.set_facecolor(NAPARI_WINDOW_COLOR)

# changing colors of all axes
[
self.axes.spines[spine].set_color("white")
for spine in self.axes.spines
]
self.axes.xaxis.label.set_color("white")
self.axes.yaxis.label.set_color("white")

# changing colors of axes labels
self.axes.tick_params(axis="x", colors="white")
self.axes.tick_params(axis="y", colors="white")

def _on_update_layers(self) -> None:
"""
This function is called when self.layers is updated via
Expand Down
1 change: 1 addition & 0 deletions 1 src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class HistogramWidget(NapariMPLWidget):
def __init__(self, napari_viewer: napari.viewer.Viewer):
super().__init__(napari_viewer)
self.axes = self.canvas.figure.subplots()
self.apply_napari_colorscheme()
self.update_layers(None)

def clear(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions 1 src/napari_matplotlib/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, napari_viewer: napari.viewer.Viewer):
super().__init__(napari_viewer)

self.axes = self.canvas.figure.subplots()
self.apply_napari_colorscheme()
self.update_layers(None)

def clear(self) -> None:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.