Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing code before/after each cell #5892

Open
nobodyinperson opened this issue Dec 1, 2020 · 0 comments
Open

Executing code before/after each cell #5892

nobodyinperson opened this issue Dec 1, 2020 · 0 comments

Comments

@nobodyinperson
Copy link

Hi,

I was wondering if it is possible to make it so that before (or after) each cell a certain function is run?

For example, I always use %matplotlib notebook for interactive plots, but when I want to do a new plot in a new cell, I must either again execute %matplotlib notebook or close all plots by running plt.close("all"), otherwise the plots gets shown in the previous interactive window. It would be very convenient to have Jupyter run plt.close("all") before (or after) each cell in this case.

I'm surely not the only one annoyed by this %matplotlib notebook behaviour (see #1151) and in this case it might just be a long-running bug with that, but and in general there certainly are other uses for some kind of before/after cell hooks.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant