@@ -853,6 +853,12 @@ def getdefault(self, key):
853
853
854
854
return self ._get_default (key )
855
855
856
+ def getdefaults (self ):
857
+ """Return default values set during initialization."""
858
+ defaults = self .copy ()
859
+ defaults .clear ()
860
+ return defaults
861
+
856
862
def _get_backend_or_none (self ):
857
863
"""Get the requested backend, if any, without triggering resolution."""
858
864
backend = self ._get ("backend" )
@@ -1110,7 +1116,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
1110
1116
return config_from_file
1111
1117
1112
1118
with _api .suppress_matplotlib_deprecation_warning ():
1113
- config = RcParams ({** rcParamsDefault , ** config_from_file })
1119
+ config = RcParams ({** rcParams . getdefaults () , ** config_from_file })
1114
1120
1115
1121
if "" .join (config ['text.latex.preamble' ]):
1116
1122
_log .info ("""
@@ -1125,21 +1131,22 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
1125
1131
return config
1126
1132
1127
1133
1128
- rcParamsDefault = _rc_params_in_file (
1134
+ rcParams = _rc_params_in_file (
1129
1135
cbook ._get_data_path ("matplotlibrc" ),
1130
1136
# Strip leading comment.
1131
1137
transform = lambda line : line [1 :] if line .startswith ("#" ) else line ,
1132
1138
fail_on_error = True )
1133
- rcParamsDefault .update (rcsetup ._hardcoded_defaults )
1139
+ for key in rcsetup ._hardcoded_defaults :
1140
+ space , subkey = key .split ("." )
1141
+ if not rcParams ._namespace_maps [space ]:
1142
+ rcParams ._namespace_maps [space ] = ChainMap ({})
1143
+ rcParams .update (rcsetup ._hardcoded_defaults )
1134
1144
# Normally, the default matplotlibrc file contains *no* entry for backend (the
1135
1145
# corresponding line starts with ##, not #; we fill on _auto_backend_sentinel
1136
1146
# in that case. However, packagers can set a different default backend
1137
1147
# (resulting in a normal `#backend: foo` line) in which case we should *not*
1138
1148
# fill in _auto_backend_sentinel.
1139
- rcParamsDefault .setdefault ("backend" , rcsetup ._auto_backend_sentinel )
1140
- rcParams = RcParams ()
1141
- rcParams ._parents ()
1142
- rcParams .update (rcParamsDefault .items ())
1149
+ rcParams .setdefault ("backend" , rcsetup ._auto_backend_sentinel )
1143
1150
rcParams .update (_rc_params_in_file (matplotlib_fname ()))
1144
1151
rcParamsOrig = rcParams .copy ()
1145
1152
with _api .suppress_matplotlib_deprecation_warning ():
@@ -1148,12 +1155,11 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
1148
1155
defaultParams = rcsetup .defaultParams = {
1149
1156
# We want to resolve deprecated rcParams, but not backend...
1150
1157
key : [(rcsetup ._auto_backend_sentinel if key == "backend" else
1151
- rcParamsDefault [ key ] ),
1158
+ rcParams . getdefault ( key ) ),
1152
1159
validator ]
1153
1160
for key , validator in rcsetup ._validators .items ()}
1154
1161
if rcParams ['axes.formatter.use_locale' ]:
1155
1162
locale .setlocale (locale .LC_ALL , '' )
1156
- rcParams ._new_child ()
1157
1163
1158
1164
1159
1165
def rc (group , ** kwargs ):
@@ -1253,8 +1259,8 @@ def rcdefaults():
1253
1259
with _api .suppress_matplotlib_deprecation_warning ():
1254
1260
from .style .core import STYLE_BLACKLIST
1255
1261
rcParams .clear ()
1256
- rcParams .update ({k : v for k , v in rcParamsDefault .items ()
1257
- if k not in STYLE_BLACKLIST })
1262
+ # rcParams.update({k: v for k, v in rcParams .items()
1263
+ # if k not in STYLE_BLACKLIST})
1258
1264
1259
1265
1260
1266
def rc_file_defaults ():
0 commit comments