E479 [Bug]: rcParams["interactive"] is overwritten if rc_context is used before anything else · Issue #24351 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: rcParams["interactive"] is overwritten if rc_context is used before anything else #24351
Closed as not planned
@timmysilv

Description

@timmysilv

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

image

Expected outcome

image

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

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

      0