title: Control scatter plot y axis order in matplotlib
body: <p>I'm trying to control the y axis order on a matplotlib scatter plot but the ordering of the x and y axes in the data I have is causing the plot to be displayed incorrectly.</p>
  <p>Here's some code to illustrate the problem and one sub-optimal attempt to make a solution.</p>
  <pre><code>import pandas as pd
  from numpy import random
  import matplotlib.pyplot as plt
  
  # make some fake data
  axes = ['a', 'b', 'c', 'd']
  pairs = pd.DataFrame([(x, y) for x in axes for y in axes], columns=['x', 'y'])
  pairs['value'] = random.randint(100, size=16) + 100
  # remove the diagonal
  pairs_nodiag = pairs[pairs['x'] != pairs['y']]
  # zero the values for the diagonal
  pairs_diag = pairs.copy()
  pairs_diag.loc[pairs_diag['x'] == pairs_diag['y'], 'value'] = 0
  
  fig, ax = plt.subplots(nrows=1, ncols=3, figsize=(5, 3))
  scatter = ax[0].scatter(x=pairs['x'], y=pairs['y'], s=pairs['value'])
  scatter = ax[1].scatter(x=pairs_nodiag['x'], y=pairs_nodiag['y'], s=pairs_nodiag['value'])
  scatter = ax[2].scatter(x=pairs_diag['x'], y=pairs_diag['y'], s=pairs_diag['value'])
  
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/UDqAJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UDqAJ.png" alt="3 plots" /></a></p>
  <p>The left most is the raw data. The middle is the plot with the problem; I want the y axis to be the same as the left most plot. The right most plot is what I am after using a sub-optimal workaround. I'm sure there is a way of controlling the ordering on the axes but I'm not expert enough in Python yet to know exactly how to do this.</p>