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

how to disable this widget for some figures? #219

Open
HYuanggg opened this issue May 7, 2020 · 9 comments
Open

how to disable this widget for some figures? #219

HYuanggg opened this issue May 7, 2020 · 9 comments

Comments

@HYuanggg
Copy link

HYuanggg commented May 7, 2020

as title. Thank you in advance.

@thomasaarholt
Copy link
Contributor

Can we assume that you mean, "and use the inline backend instead"? :) As in, use %matplotlib inline as the backend for some figures?

@HYuanggg
Copy link
Author

HYuanggg commented May 7, 2020

Can we assume that you mean, "and use the inline backend instead"? :) As in, use %matplotlib inline as the backend for some figures?

I tried '%matplotlib inline' and it is like not iteractive, which is what I want. But I think I need to add '%matplotlib inline' or '%matplotlib widget' every time I want to change from one to the other, right?

@martinRenou
Copy link
Member

martinRenou commented May 7, 2020

Yeah that would be it.. There is no way, I suppose, to do otherwise.

@HYuanggg
Copy link
Author

HYuanggg commented May 7, 2020

Yeah that would be it.. There is no way, I suppose, to do otherwise.

Thank you Martin

@thomasaarholt
Copy link
Contributor

This issue is a bit more general than ipympl, I think. I've wondered a lot about the general matplotlib backend implementation in jupyter - like how one cannot switch between the various interactive backends without restarting the kernel, for instance.

@martinRenou
Copy link
Member

This is completely dependent to ipython actually, ipython implements the magics that decide how matplotlib behaves.

@ianhi
Copy link
Collaborator

ianhi commented Jul 29, 2020

Does the below achieve what you want?

plt.ioff(); fig = plt.figure(); plt.ion()
# whatever plotting you want
display(fig)

Using ioff prevents the automatic display of the figure on it's creation, and then if you display(fig) instead of display(fig.canvas) you will get a png as output like the inline backend.

@hckr
Copy link

hckr commented Jun 2, 2022

@ianhi I think you didn't mean to write plt.ioff() the second time, but rather plt.ion()?

The following works for me:

with plt.ioff():
    fig = plt.figure()
    # ...
    display(fig)

@ianhi
Copy link
Collaborator

ianhi commented Jun 2, 2022

@ianhi I think you didn't mean to write plt.ioff() the second time, but rather plt.ion()?

good catch!. I edited it to be the correct thing

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

5 participants