title: Plot 2D data with xarray (pcolormesh) while keeping aspect ratio
body: <p>I am trying to plot a 2D data set using xarray (which uses <a href="https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pcolormesh.html#matplotlib.pyplot.pcolormesh" rel="nofollow noreferrer">matplotlib.pcolormesh</a>) while keeping the natural aspect ratio of the data.</p>
  
  <p>Example:</p>
  
  <pre><code>import xarray as xr
  import matplotlib.pyplot as plt
  
  plt.close('all')
  data = xr.DataArray(np.random.randn(2, 3), dims=('x', 'y'),coords={'x': [10, 20],'y' : [0,50,100]})
  data.plot() # Will produce a square plot
  </code></pre>
  
  <p>The result is </p>
  
  <p><img src="https://i.stack.imgur.com/2giah.png" width="300"></p>
  
  <p>Adding a <code>plt.gca().set_aspect('equal')</code> does scale the plot in the way I want, however, the height of the colorbar is unchanged yielding</p>
  
  <p><img src="https://i.stack.imgur.com/FZ6Bi.png" width="300"></p>
  
  <p>Using the parameters <code>size</code>, <code>aspect</code>, or <code>figsize</code> does not help either. 
  For the above example:</p>
  
  <pre><code>data.plot(size=6, aspect=150 / 30. * 6)
  </code></pre>
  
  <p>(or with the same result <code>data.plot(figsize=(150 / 30. * 6,6))</code>)</p>
  
  <p><img src="https://i.stack.imgur.com/sWaA3.png" width="300"></p>
  
  <p>which is better but still off (maybe due to the colorbar?).</p>