Skip to content

Closing a figure from the notebook does not close the python figure #4

Open
@jenshnielsen

Description

This is essentially a regression of matplotlib/matplotlib#4841 which happened when the nbagg backend was converted to a widget.

To reproduce create a cell with a simple plot.

plt.plot(range(10))
plt.show()

re execute the cell and observe that the figure count goes up and memory consumption goes up too. If you continue doing this you will eventually have more than 20 open figures and matplotlib will print a warning even if you only have one figure displayed.

The same is true if you explicitly close the widget using the widget close cross on the left of the figure.

I have spent some time trying to figure out how to best fix this but don't really know how to best do this. This function
is meant to trigger a close message to the python side when the figure is removed from the DOM but no longer works.

The old no longer existing close button is also intended to send a close signal to the python layer but this is not hooked up to the widget close button.

matplotlib/matplotlib#6414 has some more related issues.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions