title: How to assign a plot to a variable and use the variable as the return value in a Python function
body: <p>I am creating two Python scripts to produce some plots for a technical report. In the first script I am defining functions that produce plots from raw data on my hard-disk. Each function produces one specific kind of plot that I need. The second script is more like a batch file which is supposed to loop around those functions and store the produced plots on my hard-disk.</p>
  
  <p>What I need is a way to return a plot in Python. So basically I want to do this:</p>
  
  <pre><code>fig = some_function_that_returns_a_plot(args)
  fig.savefig('plot_name')
  </code></pre>
  
  <p>But what I do not know is how to make a plot a variable that I can return. Is this possible? Is so, how?</p>