title: python matplotlib 2.x axis autolimit
body: <p>I've got a problem with matplotlib 2.x code not reproducing 1.x behaviour, when it comes to choosing the auto-limits on the axes. According to <a href="https://matplotlib.org/users/dflt_style_changes.html" rel="nofollow noreferrer">https://matplotlib.org/users/dflt_style_changes.html</a> , version 1.x axis rounding should be reproduced by the using the commands:</p>
  
  <pre><code>mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
  mpl.rcParams['axes.xmargin'] = 0
  mpl.rcParams['axes.ymargin'] = 0
  </code></pre>
  
  <p>But it doesn't. See the code below. My y values range from just above 5 to just below 50. When I run the code:</p>
  
  <ul>
  <li>with classic (version 1.x) behaviour (sys.argv[1]=="1"), the y axis ticks are 5 and 50. </li>
  <li>with version 2.x behaviour (sys.argv[1]=="2") the y axis ticks are 0 and 60.</li>
  </ul>
  
  <p>Version 2.x rounding appears to be coarser. How do I reproduce version 1.x rounding?</p>
  
  <pre><code>import sys
  import matplotlib.pyplot as plt
  import matplotlib as mpl
  
  if sys.argv[1]=="1":
      import matplotlib.style
      matplotlib.style.use('classic')
  elif sys.argv[1]=="2":
      mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
      mpl.rcParams['axes.xmargin'] = 0
      mpl.rcParams['axes.ymargin'] = 0
  else:
      raise Exception("param must be 1 or 2")
  
  z = [49.0, 14.5, 6.0, 5.8]
  steps = len(z)
  
  plt.clf()
  plt.figure(figsize=(8,6)) # Matplotlib 1.x default
  plt.subplot(311)
  plt.plot(range(steps), z)
  
  plt.xlim(xmin=0, xmax=steps-1)
  plt.xticks(range(steps))
  ymin, ymax = plt.ylim()
  plt.yticks([ymin, ymax])
  
  plt.savefig("mpltest%s.pdf" % sys.argv[1])
  </code></pre>