File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -1254,13 +1254,10 @@ def rcdefaults():
1254
1254
Use a specific style file. Call ``style.use('default')`` to restore
1255
1255
the default style.
1256
1256
"""
1257
- # Deprecation warnings were already handled when creating rcParamsDefault,
1258
- # no need to reemit them here.
1259
- with _api .suppress_matplotlib_deprecation_warning ():
1260
- from .style .core import STYLE_BLACKLIST
1261
- rcParams .clear ()
1262
- # rcParams.update({k: v for k, v in rcParams.items()
1263
- # if k not in STYLE_BLACKLIST})
1257
+ # # Deprecation warnings were already handled when creating rcParamsDefault,
1258
+ # # no need to reemit them here.
1259
+ from .style import core
1260
+ core .use ('default' )
1264
1261
1265
1262
1266
1263
def rc_file_defaults ():
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ def use(style):
149
149
else :
150
150
filtered [k ] = style [k ]
151
151
mpl .rcParams .update (filtered )
152
+ mpl .rcParams ._new_child ()
152
153
153
154
154
155
@contextlib .contextmanager
Original file line number Diff line number Diff line change @@ -664,3 +664,17 @@ def test_rcparams_getdefaults():
664
664
defaults = mpl .rcParams .getdefaults ()
665
665
mpl .rcParams .clear ()
666
666
assert defaults == mpl .rcParams
667
+
668
+
669
+ def test_rcdefaults ():
670
+ # webagg.port is a style blacklisted key that shouldn't be
671
+ # updated when resetting rcParams to default values.
672
+ mpl .rcParams ["webagg.port" ] = 9000
673
+ # lines.linewidth is not a style blacklisted key and should be
674
+ # reset to the default value.
675
+ # breakpoint()
676
+ lw = mpl .rcParams .getdefault ("lines.linewidth" )
677
+ mpl .rcParams ["lines.linewidth" ] = lw + 1
678
+ mpl .rcdefaults ()
679
+ assert mpl .rcParams ["webagg.port" ] == 9000
680
+ assert mpl .rcParams ["lines.linewidth" ] == lw
You can’t perform that action at this time.
0 commit comments