File tree 2 files changed +30
-0
lines changed
src/napari_matplotlib/tests
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -88,3 +88,33 @@ def test_titles_respect_theme(
88
88
89
89
assert ax .xaxis .label .get_color () == expected_text_colour
90
90
assert ax .yaxis .label .get_color () == expected_text_colour
91
+
92
+
93
+ @pytest .mark .mpl_image_compare
94
+ def test_no_theme_side_effects (make_napari_viewer ):
95
+ """Ensure that napari-matplotlib doesn't pollute the globally set style.
96
+
97
+ A MWE to guard aganst issue matplotlib/#64. Should always reproduce a plot
98
+ with the default matplotlib style.
99
+ """
100
+ import matplotlib .pyplot as plt
101
+
102
+ np .random .seed (12345 )
103
+
104
+ # should not affect global matplotlib plot style
105
+ viewer = make_napari_viewer ()
106
+ viewer .theme = "dark"
107
+ NapariMPLWidget (viewer )
108
+
109
+ # some plotting unrelated to napari-matplotlib
110
+ normal_dist = np .random .normal (size = 1000 )
111
+ unrelated_figure , ax = plt .subplots ()
112
+ ax .hist (normal_dist , bins = 100 )
113
+ ax .set_xlabel ("something unrelated to napari (x)" )
114
+ ax .set_ylabel ("something unrelated to napari (y)" )
115
+ ax .set_title (
116
+ "this plot style should not change with napari styles or themes"
117
+ )
118
+ unrelated_figure .tight_layout ()
119
+
120
+ return unrelated_figure
You can’t perform that action at this time.
0 commit comments