title: Matplotlib returning a plot object
body: <p>I have a function that wraps <code>pyplot.plt</code> so I can quickly create graphs with oft-used defaults:</p>
  
  <pre><code>def plot_signal(time, signal, title='', xlab='', ylab='',
                  line_width=1, alpha=1, color='k',
                  subplots=False, show_grid=True, fig_size=(10, 5)):
  
      # Skipping a lot of other complexity here
  
      f, axarr = plt.subplots(figsize=fig_size)
      axarr.plot(time, signal, linewidth=line_width,
                 alpha=alpha, color=color)
      axarr.set_xlim(min(time), max(time))
      axarr.set_xlabel(xlab)
      axarr.set_ylabel(ylab)
      axarr.grid(show_grid)
  
      plt.suptitle(title, size=16)
      plt.show()
  </code></pre>
  
  <p>However, there are times where I'd want to be able to return the plot so I can manually add/edit things for a specific graph. For example, I want to be able to change the axis labels, or add a second line to the plot after calling the function:</p>
  
  <pre><code>import numpy as np
  
  x = np.random.rand(100)
  y = np.random.rand(100)
  
  plot = plot_signal(np.arange(len(x)), x)
  
  plot.plt(y, 'r')
  plot.show()
  </code></pre>
  
  <p>I've seen a few questions on this (<a href="https://stackoverflow.com/questions/14936646/how-to-return-a-matplotlib-figure-figure-object-from-pandas-plot-function">How to return a matplotlib.figure.Figure object from Pandas plot function?</a> and <a href="https://stackoverflow.com/questions/38701137/attributeerror-figure-object-has-no-attribute-plot">AttributeError: &#39;Figure&#39; object has no attribute &#39;plot&#39;</a>) and as a result I've tried adding the following to the end of the function:</p>
  
  <ul>
  <li><p><code>return axarr</code></p></li>
  <li><p><code>return axarr.get_figure()</code></p></li>
  <li><p><code>return plt.axes()</code></p></li>
  </ul>
  
  <p>However, they all return a similar error: <code>AttributeError: 'AxesSubplot' object has no attribute 'plt'</code></p>
  
  <p>Whats the correct way to return a plot object so it can be edited later?</p>