[Bug]: Inconsistent behavior of stylesheet contexts in Jupyter Notebooks · Issue #30170 · matplotlib/matplotlib · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

[Bug]: Inconsistent behavior of stylesheet contexts in Jupyter Notebooks #30170

Open
@janikkokot

Description

@janikkokot

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

Image

custom style with context

Image

custom style with use

Image

in one code cell

default style with use

Image

custom style with context

Image

custom style with use

Image

Expected outcome

default style with use

Image

custom style with context

Image

custom style with use

Image

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.