title: matplotlib get ylim values
body: <p>I'm using <code>matplotlib</code> to plot data (using <code>plot</code> and <code>errorbar</code> functions) from Python.  I have to plot a set of totally separate and independent plots, and then adjust their <code>ylim</code> values so they can be easily visually compared.</p>
  
  <p>How can I retrieve the <code>ylim</code> values from each plot, so that I can take the min and max of the lower and upper ylim values, respectively, and adjust the plots so they can be visually compared?</p>
  
  <p>Of course, I could just analyze the data and come up with my own custom <code>ylim</code> values... but I'd like to use <code>matplotlib</code> to do that for me.  Any suggestions on how to easily (and efficiently) do this?</p>
  
  <p>Here's my Python function that plots using <code>matplotlib</code>:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  def myplotfunction(title, values, errors, plot_file_name):
  
      # plot errorbars
      indices = range(0, len(values))
      fig = plt.figure()
      plt.errorbar(tuple(indices), tuple(values), tuple(errors), marker='.')
  
      # axes
      axes = plt.gca()
      axes.set_xlim([-0.5, len(values) - 0.5])
      axes.set_xlabel('My x-axis title')
      axes.set_ylabel('My y-axis title')
  
      # title
      plt.title(title)
  
      # save as file
      plt.savefig(plot_file_name)
  
      # close figure
      plt.close(fig)
  </code></pre>