I want to create a graph with a function, it will return the fig so later, I can re-display it when necessary.
The function is performed as follows:
def simple_plot(ax = None): if ax is None: fig, ax = plt.subplots() a = [1,2,3,4] b = [3,4,5,6] plt.plot(a, b,'-', color='black') return fig
If I run simple_plot() , it will print the graph twice, for example:

Please note: if I run fig = simple_plot() , it will print only once, and I can use fig to play the graph later on in the Ipython Notebook
How can I do this only once if I run simple_plot() ?
I'm not sure if I defined the function correctly, which would be a good way to define a function to create a graph?
source share