8000 nbagg: "Close figure" action does not 'close' the figure object · Issue #4281 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
nbagg: "Close figure" action does not 'close' the figure object #4281
Closed
@jorisvandenbossche

Description

@jorisvandenbossche

I am not fully sure how the notebook backend is supposed to work (and I also did not found any documentation on it?), but the following did surprise me a bit:

%matplotlib notebook

import matplotlib.pyplot as plt
import numpy as np

t = np.linspace(0, 2*np.pi, 1024)
plt.plot(t, np.sin(t), t, -np.sin(t))

The above creates an interactive figure in the notebook.
But when I close it (the red button with cross) and the figure is displayed in the notebook as a static image, a subsequent plotting call does nothing:

plt.plot(t, np.sin(t), t, np.cos(t))

It is only when I explicitely create a new figure that it is displayed:

plt.figure()
plt.plot(t, np.sin(t), t, np.cos(t))

or if I explicitly close the previous figures with e.g. plt.close('all').

So to me it seems like the plt.plot call is still seeing the original figure as the current figure and so trying to plot it on this original figure, but as this is already displayed as a static image in the previous cell, this does not do anything.

I don't know if this is on purpose, but e.g. with the qt or gtk backend when you close a figure, plt.plot will create a new figure automatically, and not trying to plot on the current figure anymore (as this is closed).


matplotlib 1.4.3, ipython 3.0, windows 7

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0