File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
doc/api/next_api_changes/behavior Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change
1
+ mpl.rc_context no longer resets the value of ``'backend' ``
2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
+
4
+ `matplotlib.rc_context ` incorrectly reset the value of :rc: `backend ` if backend
5
+ resolution was triggered in the context. This affected only the value. The actual backend
6
+ was not changed. Now, `matplotlib.rc_context ` does not reset :rc: `backend ` anymore.
Original file line number Diff line number Diff line change @@ -1059,6 +1059,8 @@ def rc_context(rc=None, fname=None):
1059
1059
"""
1060
1060
Return a context manager for temporarily changing rcParams.
1061
1061
1062
+ The :rc:`backend` will not be reset by the context manager.
1063
+
1062
1064
Parameters
1063
1065
----------
1064
1066
rc : dict
@@ -1087,7 +1089,8 @@ def rc_context(rc=None, fname=None):
1087
1089
plt.plot(x, y) # uses 'print.rc'
1088
1090
1089
1091
"""
1090
- orig = rcParams .copy ()
1092
+ orig = dict (rcParams .copy ())
1093
+ del orig ['backend' ]
1091
1094
try :
1092
1095
if fname :
1093
1096
rc_file (fname )
Original file line number Diff line number Diff line change @@ -496,6 +496,13 @@ def test_keymaps():
496
496
assert isinstance (mpl .rcParams [k ], list )
497
497
498
498
499
+ def test_no_backend_reset_rccontext ():
500
+ assert mpl .rcParams ['backend' ] != 'module://aardvark'
501
+ with mpl .rc_context ():
502
+ mpl .rcParams ['backend' ] = 'module://aardvark'
503
+ assert mpl .rcParams ['backend' ] == 'module://aardvark'
504
+
505
+
499
506
def test_rcparams_reset_after_fail ():
500
507
# There was previously a bug that meant that if rc_context failed and
501
508
# raised an exception due to issues in the supplied rc parameters, the
You can’t perform that action at this time.
0 commit comments