subplot2grid with seaborn overwrites same ax
<p>What is the correct way of specifying the ax where I want a chart to go?</p>

<p>Currently I'm trying to plot different heatmaps, each one in a different ax. But  when trying this it just plots the 2 charts one on top of the other. </p>

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

fig3 = plt.figure(figsize=(12,10))

ax1     = plt.subplot2grid((11,2),(0,0), rowspan=3, colspan=1)
ax2     = plt.subplot2grid((11,2),(4,0), rowspan=3, colspan=1)

ax1 = sns.heatmap(dict_pivots['df_pivot_10_win_2_thres'], square=False, cmap="RdYlBu", 
                    linewidths=0.1, annot=True, annot_kws={"size":12})

ax2 = sns.heatmap(dict_pivots['df_pivot_5_win_2_thres'], square=False, cmap="RdYlBu", 
                    linewidths=0.1, annot=True, annot_kws={"size":12})
</code></pre>

<p>and this is how it looks:
<a href="https://i.stack.imgur.com/n0WMZ.png" rel="nofollow"><img src="https://i.stack.imgur.com/n0WMZ.png" alt="enter image description here"></a></p>

<p>You just need to pass your Axes objects to the <code>heatmap</code> function:</p>

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

fig3 = plt.figure(figsize=(12,10))

ax1 = plt.subplot2grid((11,2),(0,0), rowspan=3, colspan=1)
ax2 = plt.subplot2grid((11,2),(4,0), rowspan=3, colspan=1)

ax1 = sns.heatmap(dict_pivots['df_pivot_10_win_2_thres'],
                  square=False,  cmap="RdYlBu",
                  linewidths=0.1, annot=True,
                  annot_kws={"size":12},
                  ax=ax1)  # &lt;-- here

ax2 = sns.heatmap(dict_pivots['df_pivot_5_win_2_thres'],
                  square=False,  cmap="RdYlBu",
                  linewidths=0.1, annot=True,
                  annot_kws={"size":12},
                  ax=ax2)  # &lt;-- and here
</code></pre>

python matplotlib seaborn