I want to do the following in a Jupyter Notebook:
pyplot.figure
in a cell;You can capture the content of a cell of a jupyter notebook using the magic command %%capture
. You can also hide any output of a specific line by putting a ;
at the end of it.
Showing the figure can be done by simply typing the variable in which the figure is stored, e.g. fig
.
Combining those techniques gives you
import matplotlib.pyplot as plt
%matplotlib notebook
%%capture captured
fig, ax=plt.subplots()
ax.plot([1,2,3]);
fig # now show the figure
which is probably more understandable in the acutal notebook like this:
Also see How to overlay plots from different cells?