If I comment out '%matplotlib inline' the code runs fine
But if I leave '%matplotlib inline' uncommented, 'fig, axes = plt.subplots(nrows=x_p, ncols=y_p)' starts to create blank plots, and following code triggers error as below. Any idea why?
Matplotlib Jupyter – Fixing ‘%matplotlib inline’ Error
jupyter-notebookmatplotlib
Best Answer
By default, figures are closed at the end of a cell. This means that pyplot (
plt
) has forgotten about the axes to work on in the next cell.tells us:
The solution is thus to set
.close_figures
to False:In order to prevent the automatic output of active figures at the end of a cell, you may then set
plt.ioff()
.