matplotlib / matplotlib/ipympl

Closing figures does not work

Open
#427 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
1.7k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

How to reproduce
%matplotlib widget

import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(1)
plt.plot(np.sin(np.linspace(0, 20, 100)))

and then

plt.close(1)
Expected behaviour

Plotting canvas disappears.

Actual behaviour

Figure becomes non-interactive (tools do not work anymore), but canvas is still visible.

Versions

sys.version: 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]
ipympl version: 0.8.7
Jupyter notebook running locally in a VS code (version 1.63.2), jupyter extension v2021.11.1001550889

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example in a local VS Code Jupyter notebook using ipympl 0.8.7, then trace how plt.close(1) affects the visible canvas and its interactivity. The work is done when closing the figure removes the plotting canvas, while the reproduction no longer leaves a visible non-interactive figure.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, jupyter-notebook
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.