Getting the same subplot size using matplotlib imshow and scatter : <p>I am trying to plot an image (using <code>matplotlib.imshow</code>) and a scatter plot within the same figure. When trying this, the image appears smaller than the scatter plot. Small example code is shown below:</p>

<pre><code>import matplotlib.pyplot as plt
import numpy as np

image = np.random.randint(100,200,(200,200))
x = np.arange(0,10,0.1)
y = np.sin(x)

fig, (ax1, ax2) = plt.subplots(1,2)
ax1.imshow(image)
ax2.scatter(x,y)

plt.show()
</code></pre>

<p>Which gives the following figure:</p>

<p><a href="https://i.stack.imgur.com/zkHti.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zkHti.png" alt="enter image description here"></a></p>

<p>How can I get the two sublpots to have the same height? (and width I suppose)</p>

<p>I have tried using <a href="http://matplotlib.org/users/gridspec.html" rel="noreferrer"><code>gridspec</code></a> as shown in <a href="https://stackoverflow.com/questions/10388462/matplotlib-different-size-subplots">this</a> answer:</p>

<pre><code>fig=plt.figure()
gs=GridSpec(1,2)

ax1=fig.add_subplot(gs[0,0])
ax2=fig.add_subplot(gs[0,1])
ax1.imshow(image)
ax2.scatter(x,y)
</code></pre>

<p>But this gives the same result. I have also tried to adjust the subplot sizes manually by using:</p>

<pre><code>fig = plt.figure()
ax1 = plt.axes([0.05,0.05,0.45,0.9])
ax2 = plt.axes([0.55,0.19,0.45,0.62])

ax1.imshow(image)
ax2.scatter(x,y)
</code></pre>

<p>By trial and error I can get the two subplots to the correct size, though any change in the overall figure size will mean that the subplots will no longer be the same size.</p>

<p>Is there a way to make <code>imshow</code> and a <code>scatter</code> plot appear the same size in a figure without manually changing the axes sizes?</p>

<p>I am using Python 2.7 and matplotlib 2.0.0</p>
