title: Why is Pandas inverting my x-axis order?
body: <p>When I was plotting two series of data against eachother, the X axis was inverted unexpectedly. I know this question sounds pretty similar to this other: <a href="https://stackoverflow.com/questions/29908874/x-axis-inverted-unexpectedly-by-pandas-plot/29912696#29912696">x-axis inverted unexpectedly by pandas.plot(...)</a> and it actually is, but I want to know if this can be disabled or something, not a workaround. Let me explain myself. </p>
  
  <p>I have a very simple DF that consists on a datetime index and two columns; one has humidity measurements and the other daily weights. Both of them are in descending order because when my sample loses water, it also loses weight and humidity. So my DF looks something like this, where my data is in descending order </p>
  
  <p><img src="https://i.stack.imgur.com/pUwYW.png" alt="DF - my data is in descending order"></p>
  
  <p>But then, when I plot using X = "Peso" (weight), and Y = 'Humedad' (humidity), my X axis goes in ascending order insted of descending order. </p>
  
  <p>My ploting code: </p>
  
  <pre><code>plt.figure(figsize=(12,9))
  plt.scatter(data['Peso'],data['Humedad'])
  plt.xlabel('Peso (kg)',fontsize=14)
  plt.ylabel("Raw Counts",fontsize=14)
  plt.xticks(rotation=90,fontsize=10)
  plt.grid()
  </code></pre>
  
  <p>Resulting in this kind of plot, where X axis is inverted</p>
  
  <p><img src="https://i.stack.imgur.com/vQ7IK.png" alt="First plot - X axis inverted"></p>
  
  <p>So, I could do two simple types of workaround:</p>
  
  <pre><code>plt.scatter(sorted(data['Peso']),data['Humedad']) 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>plt.scatter(data['Peso'][::-1],data['Humedad'])
  </code></pre>
  
  <p>Both of them have the same result, they print my data as I wanted, BUT my xticks are still inverted:</p>
  
  <p><img src="https://i.stack.imgur.com/MQ9Le.png" alt="Inverted xticks"></p>
  
  <p>So what I did was creating a list with my weight values in order to insert it as it follows: </p>
  
  <pre><code>semin=data['Peso']
  semin=semin.tolist()
  </code></pre>
  
  <p>And then adding it to my plt.xticks like this</p>
  
  <pre><code>plt.xticks(semin,rotation=90,fontsize=10)
  </code></pre>
  
  <p>It "kind off" worked, overlaping some of the xticks as you can see in the image below:</p>
  
  <p><img src="https://i.stack.imgur.com/Tiuo8.png" alt="More xticks problems"></p>
  
  <p>I know I can solve this with [Locs] and general xticks information, but I really wanted to know if <strong>it's possible to just ask Pandas to follow the natural data descending order or anything similiar and avoiding all of this xticks stuff?</strong></p>
  
  <p>I've checked this too: <a href="https://github.com/pandas-dev/pandas/issues/10118" rel="nofollow noreferrer">https://github.com/pandas-dev/pandas/issues/10118</a> 
  and I tried by doing the set_index suggestion:</p>
  
  <pre><code>plt.figure(figsize=(12,9))
  data.set_index('Peso').Humedad.plot()
  plt.xlabel('Peso (kg)',fontsize=14)
  plt.ylabel("Raw Counts",fontsize=14)
  plt.xticks(rotation=90,fontsize=10)
  plt.grid() 
  </code></pre>
  
  <p>And it went almost perfect, except that I needed it in scatter... </p>
  
  <p><img src="https://i.stack.imgur.com/UUojI.png" alt="Almost there"></p>
  
  <p>So I tried some stuff to "scatter it"</p>
  
  <p><strong>1.</strong> Putting the marker type:</p>
  
  <pre><code>data.set_index('Peso').Humedad.plot(marker='o')
  </code></pre>
  
  <p>Got a marker + line graph:</p>
  
  <p><img src="https://i.stack.imgur.com/VbT23.png" alt="Marker &#39;o&#39;"></p>
  
  <p><strong>2.</strong> Changing .plot for .scatter to the plot:</p>
  
  <pre><code>data.set_index('Peso').Humedad.scatter()
  </code></pre>
  
  <p>Got this error:</p>
  
  <blockquote>
    <p>AttributeError: 'Series' object has no attribute 'scatter'</p>
  </blockquote>
  
  <p><strong>3.</strong> Using both</p>
  
  <pre><code>data.set_index('Peso').Humedad.plot.scatter()
  </code></pre>
  
  <p>Got this one:</p>
  
  <blockquote>
    <p>AttributeError: 'SeriesPlotMethods' object has no attribute 'scatter'</p>
  </blockquote>
  
  <p><strong>4.</strong> Making this giant question. Please help. </p>
  
  <p>And that's all, sorry if I'm missing something or if my post is too long. I'm open to suggestions, corrections or anything you're willing to tell me. </p>
  
  <p>Thanks! </p>