@@ -776,12 +776,12 @@ def __setitem__(self, key, val):
776
776
return
777
777
elif key == 'backend' or key == "default.backend" :
778
778
if val is rcsetup ._auto_backend_sentinel :
779
- if 'backend' in self :
779
+ if 'backend' in self or 'default.backend' in self :
780
780
return
781
- if key in self .single_key_set :
782
- key = f"default.{ key } "
783
781
try :
784
782
cval = self .validate [key ](val )
783
+ if key in self .single_key_set :
784
+ key = f"default.{ key } "
785
785
except ValueError as ve :
786
786
raise ValueError (f"Key { key } : { ve } " ) from None
787
787
self ._set (key , cval )
@@ -846,7 +846,7 @@ def __contains__(self, key):
846
846
def __iter__ (self ):
847
847
"""Yield from sorted list of keys"""
848
848
keys = (
849
- "." .join ((space , key ))
849
+ "." .join ((space , key )) if space != 'default' else key
850
850
for space , mapping in self ._namespace_maps .items ()
851
851
for key in mapping .keys ()
852
852
)
@@ -1018,8 +1018,6 @@ def _rc_params_in_file(fname, transform=lambda x: x, fail_on_error=False):
1018
1018
config = RcParams ()
1019
1019
1020
1020
for key , (val , line , line_no ) in rc_temp .items ():
1021
- if key in config .single_key_set :
1022
- key = f"default.{ key } "
1023
1021
if key in rcsetup ._validators :
1024
1022
if fail_on_error :
1025
1023
config [key ] = val # try to convert to proper type or raise
@@ -1096,23 +1094,22 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
1096
1094
# in that case. However, packagers can set a different default backend
1097
1095
# (resulting in a normal `#backend: foo` line) in which case we should *not*
1098
1096
# fill in _auto_backend_sentinel.
1099
- rcParamsDefault .setdefault ("default. backend" , rcsetup ._auto_backend_sentinel )
1100
- params_dict = RcParams ()
1101
- params_dict .update (rcParamsDefault .items ())
1102
- params_dict .update (_rc_params_in_file (matplotlib_fname ()))
1103
- rcParamsOrig = params_dict .copy ()
1097
+ rcParamsDefault .setdefault ("backend" , rcsetup ._auto_backend_sentinel )
1098
+ rcParams = RcParams ()
1099
+ rcParams .update (rcParamsDefault .items ())
1100
+ rcParams .update (_rc_params_in_file (matplotlib_fname ()))
1101
+ rcParamsOrig = rcParams .copy ()
1104
1102
with _api .suppress_matplotlib_deprecation_warning ():
1105
1103
# This also checks that all rcParams are indeed listed in the template.
1106
1104
# Assigning to rcsetup.defaultParams is left only for backcompat.
1107
1105
defaultParams = rcsetup .defaultParams = {
1108
1106
# We want to resolve deprecated rcParams, but not backend...
1109
- key : [(rcsetup ._auto_backend_sentinel if key == "default. backend" else
1107
+ key : [(rcsetup ._auto_backend_sentinel if key == "backend" else
1110
1108
rcParamsDefault [key ]),
1111
1109
validator ]
1112
1110
for key , validator in rcsetup ._validators .items ()}
1113
- if params_dict ['axes.formatter.use_locale' ]:
1111
+ if rcParams ['axes.formatter.use_locale' ]:
1114
1112
locale .setlocale (locale .LC_ALL , '' )
1115
- rcParams = RcParams (params_dict )
1116
1113
1117
1114
1118
1115
def rc (group , ** kwargs ):
@@ -1388,14 +1385,14 @@ def use(backend, *, force=True):
1388
1385
# value which will be respected when the user finally imports
1389
1386
# pyplot
1390
1387
else :
1391
- rcParams ['default. backend' ] = backend
1388
+ rcParams ['backend' ] = backend
1392
1389
# if the user has asked for a given backend, do not helpfully
1393
1390
# fallback
1394
- rcParams ['default. backend_fallback' ] = False
1391
+ rcParams ['backend_fallback' ] = False
1395
1392
1396
1393
1397
1394
if os .environ .get ('MPLBACKEND' ):
1398
- rcParams ['default. backend' ] = os .environ .get ('MPLBACKEND' )
1395
+ rcParams ['backend' ] = os .environ .get ('MPLBACKEND' )
1399
1396
1400
1397
1401
1398
def get_backend ():
@@ -1413,7 +1410,7 @@ def interactive(b):
1413
1410
"""
1414
1411
Set whether to redraw after every plotting command (e.g. `.pyplot.xlabel`).
1415
1412
"""
1416
- rcParams ['default. interactive' ] = b
1413
+ rcParams ['interactive' ] = b
1417
1414
1418
1415
1419
1416
def is_interactive ():
@@ -1425,7 +1422,7 @@ def is_interactive():
1425
1422
This function is only intended for use in backends. End users should
1426
1423
use `.pyplot.isinteractive` instead.
1427
1424
"""
1428
- return rcParams ['default. interactive' ]
1425
+ return rcParams ['interactive' ]
1429
1426
1430
1427
1431
1428
def _init_tests ():
0 commit comments