How to align y labels in a Seaborn PairGrid
<p>Taken from the <a href="https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.PairGrid.html" rel="nofollow">documentation</a>:</p>

<pre><code>&gt;&gt;&gt; import matplotlib.pyplot as plt
&gt;&gt;&gt; import seaborn as sns; sns.set()
&gt;&gt;&gt; iris = sns.load_dataset("iris")
&gt;&gt;&gt; g = sns.PairGrid(iris)
&gt;&gt;&gt; g = g.map(plt.scatter)
</code></pre>

<p><a href="http://i.stack.imgur.com/paMfN.png" rel="nofollow"><img src="http://i.stack.imgur.com/paMfN.png" alt="PairGrid"></a></p>

<p>How can I align y labels so that they do not seem as messy as they do by default?</p>

<p>What I tried:</p>

<pre><code>for ax in g.axes.flat:
    ax.yaxis.labelpad = 20
</code></pre>

<p>However, that only <em>shifts</em> all labels by the specified amount instead of aligning them.</p>

<p>Yeah, that alignment is terrible. How dare a package that boasts to make <a href="https://stanford.edu/~mwaskom/software/seaborn/" rel="nofollow">"attractive statistical graphics"</a> fail so abysmally at the alignment of labels?! Just kidding, I love me some seaborn, at least for inspiration on how to improve my own plots.</p>

<p>You are looking for:</p>

<pre><code>ax.get_yaxis().set_label_coords(x,y) # conveniently in axis coordinates
</code></pre>

<p>Also, I would only iterate over the axes that show the label, but that is just me:</p>

<pre><code>for ax in g.axes[:,0]:
    ax.get_yaxis().set_label_coords(-0.2,0.5)
</code></pre>

<p><code>0.5</code> for a centred vertical alignment, <code>-0.2</code> for a slight offset to the left (trial-and-error).</p>

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

python matplotlib seaborn