Open HYuanggg opened 4 years ago
Can we assume that you mean, "and use the inline backend instead"? :) As in, use %matplotlib inline
as the backend for some figures?
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?
Yeah that would be it.. There is no way, I suppose, to do otherwise.
Yeah that would be it.. There is no way, I suppose, to do otherwise.
Thank you Martin
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.
This is completely dependent to ipython actually, ipython implements the magics that decide how matplotlib behaves.
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.
@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 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
as title. Thank you in advance.