Open
Description
Bug summary
Under certain circumstances, when using matplotlib.style.context() to temporarily alter the default style in a Jupyter notebook, it resets the backend to no plot inline. This occurs if the plot is the first one in the notebook, but not if another plot (without the context manager) has already been plotted.
Code for reproduction
# CASE 1:
# first cell - produces inline plot with desired grid
import matplotlibl.pyplot as pl
with plt.style.context({'axes.grid': True}):
plt.plot(range(10))
# second cell - does not produce in line plot
plt.plot(range(10))
# CASE 2:
# first cell - produces inline plot
import matplotlibl.pyplot as plt
plt.plot(range(10))
# second cell - produces inline plot with desired grid
with plt.style.context({'axes.grid': True}):
plt.plot(range(10))
# third cell - produces in line plot
plt.plot(range(10))
Actual outcome
Expected outcome
In case 1, the second plot should be inline
Additional information
No response
Operating system
Windows 10.0.19045 Build 19045
Matplotlib Version
3.7.2
Matplotlib Backend
'module://matplotlib_inline.backend_inline'
Python version
3.10.10
Jupyter version
6.4.12
Installation
pip