title: Limit Range on X Axis Scatter Plot Pandas MatplotLib
body: <p>I have a dataframe that is indexed based on time, with another column indicating the number of injured pedestrians during a crash occuring at that hour. I am trying to use Matplotlib in order to graph the data, and have successfully graphed it, however, the range is much too large. I have data for one day, and would like to set the x axis limit accordingly using the min and max values calculted. I have tried using plt.set_xlim but I get an error:</p>
  
  <blockquote>
    <p>AttributeError: 'PathCollection' object has no attribute 'set_xlim'</p>
  </blockquote>
  
  <p>How can the limit be properly set?</p>
  
  <p>Graph without limits<br>
  <a href="https://i.stack.imgur.com/x9Yqz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x9Yqz.png" alt="Graph without limits"></a></p>
  
  <pre><code>df = test_request_pandas()
  df1 = df[['time','number_of_pedestrians_injured']]
  df1.set_index(['time'],inplace=True)
  df1 = df1.astype(float)
  min = df1.index.min()
  max = df1.index.max()
  fig = plt.scatter(df1.index.to_pydatetime(), df1['number_of_pedestrians_injured'])
  #fig.set_xlim([min, max]) // causing me issues
  plt.show()
  </code></pre>