Question
In Jupyter notebook, is it possible to turn off the interactive mode on a figure? The ax.plot()
does not show a line when running from the command line python but in a Jupyter notebook cell, it shows up.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(7,5))
plt.ioff()
ax.plot([1.6, 2.7]) # <--- Still the line shows up in a jupyter notebook
...
plt.ion()
plt.draw()
plt.show()
Version
$ jupyter notebook --version
6.2.0
from platform import python_version
print(python_version())
3.8.8
Related
matplotlib python inline on/off suggests using %matplotlib
but not sure why using the magic command to turn on/off the interactive mode.
It also has a mention below but not sure what it exactly means.
on and ioff set interactive mode, determining if the plot is updated after each plotting command (interactive mode on) or it waits plt.show() (if interactive mode is off). This is independent on inline, that decides if the notebook or the console should display the graphics (this happens any time the plot is updated, meaning at every plotting command if interactive mode is set with ion, or after plt.plot if unset with ioff).