Reputation: 1922
Assume that I have some data, and I want to create a plot of this data by passing it to a custom plotting function (myplot()). I am using the matplotlib's modules in myplot().
I would like myplot() to return the handle to a figure, and not plot display the plot when I call this function. Here is a sample code and output from iPython.
I have two questions regarding this:
Upvotes: 13
Views: 50160
Reputation: 224
If you do not want to start the whole notebook in non-inline-modus you can just use the following code:
%config InlineBackend.close_figures = False
def myplot(t,x):
fig = figure()
x = plot(t,x)
fig.savefig('plot.png') # This is just to show the figure is still generated
return fig
t = arange(0,6,0.01)
x = sin(t)
f = myplot(t,x)
Upvotes: 1
Reputation: 879701
Start ipython with
ipython notebook
rather than
ipython notebook --pylab=inline
Upvotes: 8