Open
Description
Bug summary
Using style sheets with the plt.style.context
context manager only updates some style changes in Jupyter Notebooks/Quarto documents.
Code for reproduction
import matplotlib.pyplot as plt
from cycler import cycler
def example_plot(line_style, scatter_style):
fig, ax = plt.subplots()
ax.plot([0, 1], [0, 1], **line_style)
ax.scatter([0, 0, 1, 1], [0, 1, 0, 1], **scatter_style)
line_style = dict(color='C1')
scatter_style = dict(color='C0', ec='C1')
rc_style = {'axes.prop_cycle': cycler(color=['#fff', '#000'])}
plt.style.use('default')
example_plot(line_style, scatter_style)
with plt.style.context(rc_style, after_reset=True):
example_plot(line_style, scatter_style)
plt.style.use(rc_style)
example_plot(line_style, scatter_style)
plt.style.use('default')
example_plot(line_style, scatter_style)
with plt.style.context(rc_style):
example_plot(line_style, scatter_style)
plt.style.use(rc_style)
example_plot(line_style, scatter_style)
Actual outcome
In separate code cells
default style with use
custom style with context
custom style with use
in one code cell
default style with use
custom style with context
custom style with use
Expected outcome
default style with use
custom style with context
custom style with use
Additional information
Quarto version: 1.7.31
Operating system
Ubuntu
Matplotlib Version
3.10.3
Matplotlib Backend
'module://matplotlib_inline.backend_inline'
Python version
Python 3.12.10
Jupyter version
7.4.3
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels