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 @@ -1249,13 +1249,10 @@ def rcdefaults():
1249
1249
Use a specific style file. Call ``style.use('default')`` to restore
1250
1250
the default style.
1251
1251
"""
1252
- # Deprecation warnings were already handled when creating rcParamsDefault,
1253
- # no need to reemit them here.
1254
- with _api .suppress_matplotlib_deprecation_warning ():
1255
- from .style .core import STYLE_BLACKLIST
1256
- rcParams .clear ()
1257
- # rcParams.update({k: v for k, v in rcParams.items()
1258
- # if k not in STYLE_BLACKLIST})
1252
+ # # Deprecation warnings were already handled when creating rcParamsDefault,
1253
+ # # no need to reemit them here.
1254
+ from .style import core
1255
+ core .use ('default' )
1259
1256
1260
1257
1261
1258
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 @@ -609,3 +609,17 @@ def test_rcparams_getdefaults():
609
609
defaults = mpl .rcParams .getdefaults ()
610
610
mpl .rcParams .clear ()
611
611
assert defaults == mpl .rcParams
612
+
613
+
614
+ def test_rcdefaults ():
615
+ # webagg.port is a style blacklisted key that shouldn't be
616
+ # updated when resetting rcParams to default values.
617
+ mpl .rcParams ["webagg.port" ] = 9000
618
+ # lines.linewidth is not a style blacklisted key and should be
619
+ # reset to the default value.
620
+ # breakpoint()
621
+ lw = mpl .rcParams .getdefault ("lines.linewidth" )
622
+ mpl .rcParams ["lines.linewidth" ] = lw + 1
623
+ mpl .rcdefaults ()
624
+ assert mpl .rcParams ["webagg.port" ] == 9000
625
+ assert mpl .rcParams ["lines.linewidth" ] == lw
You can’t perform that action at this time.
0 commit comments