prevent plot from showing in jupyter notebook prevent plot from showing in jupyter notebook python python

prevent plot from showing in jupyter notebook


Perhaps just clear the axis, for example:

fig= plt.figure()plt.plot(range(10))fig.savefig("save_file_name.pdf")plt.close()

will not plot the output in inline mode. I can't work out if is really clearing the data though.


I was able to prevent my figures from displaying by turning interactive mode off using the function

plt.ioff()


To prevent any output from a jupyter notebook cell you may start the cell with

%%capture

This might be usefull in cases all other methods shown here fail.