title: Is it possible to plot within user-defined function with python and matplotlib?
body: <p>What I want to do is define a function which contain plotting sentences. Like this:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  def myfun(args, ax):
      #...do some calculation with args
      ax.plot(...)
      ax.axis(...)
  
  fig.plt.figure()
  ax1=fig.add_subplot(121)
  ax2=fig.add_subplot(122)
  para=[[args1,ax1],[args2,ax2]]
  map(myfun, para)
  </code></pre>
  
  <p>I found that the myfun is called. If I add plt.show() in myfun, it can plot in the correct subplot, but nothing in the other one. And, if plt.show() is added in the end, nothing but two pairs of axis are plotted. I think the problem is that the figure is not transferred to the main function successfully. Is it possible to do something like this with python and matplotlib? Thanks!</p>