title: force matplotlib to show only positive numbers starting from 0 on the Y axis
body: <p>In a loop I have created some subplots using Matplotlib. </p>
  
  <p>I noticed that in some instances the Y axis (particularly when displaying 0's) shows some negative numbers on the Y axis.</p>
  
  <p>Is there a parameter to force the Y axis to display Positive numbers (i.e. from 0 upwards.</p>
  
  <p>And a parameter to make the Y axis values either one or no decimal places. (display 2 instead of 2.0 or 2.00 (which it seems to do automatically depending on the data). </p>
  
  <p><strong>code:</strong></p>
  
  <pre><code>for a in account_list:
      f = plt.figure()
      f.set_figheight(20)
      f.set_figwidth(20)
      f.sharex = True
      f.sharey=True
  
      left  = 0.125  # the left side of the subplots of the figure
      right = 0.9    # the right side of the subplots of the figure
      bottom = 0.1   # the bottom of the subplots of the figure
      top = 0.9      # the top of the subplots of the figure
      wspace = 0.2   # the amount of width reserved for blank space between subplots
      hspace = .8  # the amount of height reserved for white space between subplots
      subplots_adjust(left=left, right=right, bottom=bottom, top=top, wspace=wspace, hspace=hspace)
  
      count = 1
      for h in headings:
          sorted_data[sorted_data.account == a].ix[0:,['month_date',h]].plot(ax=f.add_subplot(7,3,count),legend=True,subplots=True,x='month_date',y=h)
  
          import matplotlib.patches as mpatches
          legend_name = mpatches.Patch(color='none', label=h)
          plt.xlabel("")
          ppl.legend(handles=[legend_name],bbox_to_anchor=(0.,1.2,1.0,.10), loc="center",ncol=2, mode="expand", borderaxespad=0.)
          count = count + 1
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DP0HH.png" alt="enter image description here"></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>When I set the minimum and maximum for the Y axis using the below: I end up with the numbers repeating. For instance where the plot used to have on the Y axis: 1, 1.5, 2, 2.5 it now just has 1, 1, 2, 2, 3, 3, (I want each number to only appear once.</p>
  
  <p>Maybe it has to do with the fact that my if statement is not working. I want all plots with a maximum Y axis value lower than ten to have their maximum Y value set to ten.</p>
  
  <pre><code>#set bottom Y axis limit to 0 and change number format to 1 dec place.
      axis_data = f.gca()
  
      from matplotlib.ticker import FormatStrFormatter
      axis_data.yaxis.set_major_formatter(FormatStrFormatter('%.0f'))
  
      #set only integers on Y axis &gt;&gt;&gt;
      import matplotlib.ticker as ticker
      axis_data.xaxis.set_major_locator(ticker.MaxNLocator(integer=True))
  
      #if y max &lt; 10 make it ten
      ymin,ymax = axis_data.get_ylim()
      print(type(ymax))
  
      if ymax &lt;10:
          axis_data.set_ylim(bottom=0.,top=ymax)
      else:
          axis_data.set_ylim(bottom=0.)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/H9gsK.png" alt="enter image description here"></p>