Bug summary
Using plt.interactive(False) or plt.ioff() in Jupyter (Lab and classic notebook) does not seem to prevent automatic figure generation, unless the magic %matplotlib inline in run first, even though the inline backend is the default.
Code for reproduction
import matplotlib.pyplot as plt
plt.interactive(False)
fig, ax = plt.subplots()
a = 0
Actual outcome

Expected outcome
Explicitly running %matplotlib inline block figure creation:

Note that running %matplotlib inline has to be done BEFORE the first figure was created, if not it has no effect

Additional information
Using the widget backend works in the same way as inline: if called before any figures are created, figures are not automatically generated. If called after one figure was made, then plt.interactive(False) has no effect.
I also tried plt.ioff() instead of plt.interactive(False) but it gives the same results.
Operating system
Ubuntu 22.04
Matplotlib Version
3.5.2
Matplotlib Backend
inline (jupyterlab)
Python version
3.9
Jupyter version
3.4.2
Installation
conda
Bug summary
Using
plt.interactive(False)orplt.ioff()in Jupyter (Lab and classic notebook) does not seem to prevent automatic figure generation, unless the magic%matplotlib inlinein run first, even though theinlinebackend is the default.Code for reproduction
Actual outcome
Expected outcome
Explicitly running

%matplotlib inlineblock figure creation:Note that running

%matplotlib inlinehas to be done BEFORE the first figure was created, if not it has no effectAdditional information
Using the
widgetbackend works in the same way asinline: if called before any figures are created, figures are not automatically generated. If called after one figure was made, thenplt.interactive(False)has no effect.I also tried
plt.ioff()instead ofplt.interactive(False)but it gives the same results.Operating system
Ubuntu 22.04
Matplotlib Version
3.5.2
Matplotlib Backend
inline (jupyterlab)
Python version
3.9
Jupyter version
3.4.2
Installation
conda