GridSpec on Seaborn Subplots
<p>I currently have 2 subplots using seaborn:</p>

<pre><code>import matplotlib.pyplot as plt
import seaborn.apionly as sns

f, (ax1, ax2) = plt.subplots(2, sharex=True)

sns.distplot(df['Difference'].values, ax=ax1) #array, top subplot

sns.boxplot(df['Difference'].values, ax=ax2, width=.4) #bottom subplot
sns.stripplot([cimin, cimax], color='r', marker='d') #overlay confidence intervals over boxplot

ax1.set_ylabel('Relative Frequency') #label only the top subplot

plt.xlabel('Difference')

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

<p>Here is the output:</p>

<p><a href="https://i.stack.imgur.com/qWzAd.png" rel="nofollow"><img src="https://i.stack.imgur.com/qWzAd.png" alt="Distribution Plot"></a></p>

<p>I am rather stumped on how to make ax2 (the bottom figure) to become shorter relative to ax1 (the top figure). I was looking over the GridSpec (<a href="http://matplotlib.org/users/gridspec.html" rel="nofollow">http://matplotlib.org/users/gridspec.html</a>) documentation but I can't figure out how to apply it to seaborn objects.</p>

<p><strong>Question:</strong></p>

<ol>
<li>How do I make the bottom subplot shorter compared to the top
subplot? </li>
<li>Incidentally, how do I move the plot's title "Distrubition of Difference" to  go above the top
subplot?</li>
</ol>

<p>Thank you for your time.</p>

<p>As @dnalow mentioned, <code>seaborn</code> has no impact on <code>GridSpec</code>, as you pass a reference to the <code>Axes</code> object to the function. Like so:</p>

<pre><code>import matplotlib.pyplot as plt
import seaborn.apionly as sns
import matplotlib.gridspec as gridspec

tips = sns.load_dataset("tips")

gridkw = dict(height_ratios=[5, 1])
fig, (ax1, ax2) = plt.subplots(2, 1, gridspec_kw=gridkw)

sns.distplot(tips.loc[:,'total_bill'], ax=ax1) #array, top subplot
sns.boxplot(tips.loc[:,'total_bill'], ax=ax2, width=.4) #bottom subplot

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

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

python matplotlib seaborn subplot