title: Keep x/y axes the same lengths in seaborn/matplotlib
body: <p>I am generating some plots using matplotlib and seaborn, and the x-axis and y-axis are different lengths as shown in an example below.</p>
  
  <p><a href="https://i.stack.imgur.com/fnYqC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fnYqC.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to ensure that each axis is of the same scale?</p>
  
  <p>My example code is nothing special, but here is an example:</p>
  
  <pre><code># plot data
  plt.scatter(df['x'], df['y'], color = 'gray', s=5) # s controls point size
  plt.xlim(-0.0002,0.002)
  plt.ylim(-0.0002,0.002)
  
  # add y=x line
  plt.plot([0,1],[0,1], lw=2, color='#414242', linestyle='dashed')
  
  sns.set_context("paper", font_scale=1.5)
  plt.xlabel(xlabel, {'size':'20'})
  plt.ylabel(ylabel, {'size':'20'})
  plt.title(title)
  
  sns.set_style('ticks')
  sns.despine(offset=10, trim=True)
  plt.xticks(rotation=45)
  plt.tight_layout()
  plt.show()
  </code></pre>
  
  <p>Using <code>plt.axis('equal')</code>:  </p>
  
  <p><a href="https://i.stack.imgur.com/g1eA5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g1eA5.png" alt="enter image description here"></a></p>