Bug summary
rcParams["interactive"] is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with @mpl.rc_context (or does some sort of caching the original rcParams), it saves the default value of interactive=False and then restores it regardless of whether or not it has been updated to True.
Code for reproduction
### in an interactive environment such as a Jupyter notebook:
import matplotlib as mpl
from matplotlib import pyplot as plt
import numpy as np
y = np.linspace(1,100,100) ** 2
with mpl.rc_context({'lines.linestyle': '--'}):
plt.plot(y)
### In another Jupyter cell:
plt.plot(y)
Actual outcome

Expected outcome

Additional information
If the value of rcParams["interactive"] was fetched and added to orig in the finally block here, this should fix it. You'd have to ensure that the calling rc or fname didn't override interactive manually, so this change might require some additional care.
Operating system
MacOS
Matplotlib Version
3.5.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.9.13
Jupyter version
6.4.12
Installation
pip
Bug summary
rcParams["interactive"]is set based on environment upon the user's first call to plot some figure. However, if that call is wrapped with@mpl.rc_context(or does some sort of caching the originalrcParams), it saves the default value ofinteractive=Falseand then restores it regardless of whether or not it has been updated to True.Code for reproduction
Actual outcome
Expected outcome
Additional information
If the value of rcParams["interactive"] was fetched and added to
origin thefinallyblock here, this should fix it. You'd have to ensure that the callingrcorfnamedidn't overrideinteractivemanually, so this change might require some additional care.Operating system
MacOS
Matplotlib Version
3.5.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.9.13
Jupyter version
6.4.12
Installation
pip