Skip to content

[Bug]: mpl.rc_context within jupyterlab prevents plot to show up #25041

Open
@fmaussion

Description

@fmaussion

Bug summary

This is arguably a very weird bug, but it is easy to reproduce. I don't know if the problem is in mpl or jupyterlab.

When using the bit of code below in a notebook, the plot shows once (and only once). Calling the function again prevents the plot to show again (see video).

I am at loss as to why this would happen 😅 . This didn't happen before, but I have no clue as to whether an update to mpl or jupyterlab created the issue.

Code for reproduction

import matplotlib as mpl
import matplotlib.pyplot as plt

figsize=(3, 3)

def plotter():
    with mpl.rc_context({"figure.figsize": figsize}):
        plt.plot([1, 2, 3])

And then:

plotter()

Actual outcome

mpl-2023-01-20_17.34.46.mp4

Expected outcome

The plot should show up on the second call.

Additional information

No response

Operating system

Linux

Matplotlib Version

3.6.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.10

Jupyter version

3.5.2

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions