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):
10591059 """
10601060 Return a context manager for temporarily changing rcParams.
10611061
1062+ The :rc:`backend` will not be reset by the context manager.
1063+
10621064 Parameters
10631065 ----------
10641066 rc : dict
@@ -1087,7 +1089,8 @@ def rc_context(rc=None, fname=None):
10871089 plt.plot(x, y) # uses 'print.rc'
10881090
10891091 """
1090- orig = rcParams .copy ()
1092+ orig = dict (rcParams .copy ())
1093+ del orig ['backend' ]
10911094 try :
10921095 if fname :
10931096 rc_file (fname )
Original file line number Diff line number Diff line change @@ -496,6 +496,13 @@ def test_keymaps():
496496 assert isinstance (mpl .rcParams [k ], list )
497497
498498
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+
499506def test_rcparams_reset_after_fail ():
500507 # There was previously a bug that meant that if rc_context failed and
501508 # raised an exception due to issues in the supplied rc parameters, the
You can’t perform that action at this time.
0 commit comments