In case there is no need for interaction for a specific matplotlib figure in a Jupyter notebook, how to prevent that programmatically?
Manually that can be done by pressing Ctrl-w or clicking the "Stop Interaction" button. I am looking for the API access to the same operation.
Reasons:
You can switch between notebook
mode with interactivity and inline
mode without such interactivity with:
%matplotlib inline
and
%matplotlib notebook
You can do this programmatically in the notebook with:
get_ipython().magic('matplotlib notebook')
or:
get_ipython().magic('matplotlib inline')
The following seems to work, though this is not ideal.
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([0,1])
plt.close(fig)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With