<p dir="auto">I tried to recreate this example to add off diagonal lines to a pairplot: <a href="https://stackoverflow.com/a/48122198/4464887" rel="nofollow">https://stackoverflow.com/a/48122198/4464887</a></p>
<p dir="auto">The code is:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

def plot_unity(xdata, ydata, **kwargs):
    mn = min(xdata.min(), ydata.min())
    mx = max(xdata.max(), ydata.max())
    points = np.linspace(mn, mx, 100)
    plt.gca().plot(points, points, color='k', marker=None,
            linestyle='--', linewidth=1.0)

ds = sns.load_dataset('iris')
grid = sns.pairplot(ds)
grid.map_offdiag(plot_unity)
plt.savefig('test.png')"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">seaborn</span> <span class="pl-k">as</span> <span class="pl-s1">sns</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-k">def</span> <span class="pl-en">plot_unity</span>(<span class="pl-s1">xdata</span>, <span class="pl-s1">ydata</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>):
    <span class="pl-s1">mn</span> <span class="pl-c1">=</span> <span class="pl-en">min</span>(<span class="pl-s1">xdata</span>.<span class="pl-en">min</span>(), <span class="pl-s1">ydata</span>.<span class="pl-en">min</span>())
    <span class="pl-s1">mx</span> <span class="pl-c1">=</span> <span class="pl-en">max</span>(<span class="pl-s1">xdata</span>.<span class="pl-en">max</span>(), <span class="pl-s1">ydata</span>.<span class="pl-en">max</span>())
    <span class="pl-s1">points</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-s1">mn</span>, <span class="pl-s1">mx</span>, <span class="pl-c1">100</span>)
    <span class="pl-s1">plt</span>.<span class="pl-en">gca</span>().<span class="pl-en">plot</span>(<span class="pl-s1">points</span>, <span class="pl-s1">points</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'k'</span>, <span class="pl-s1">marker</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,
            <span class="pl-s1">linestyle</span><span class="pl-c1">=</span><span class="pl-s">'--'</span>, <span class="pl-s1">linewidth</span><span class="pl-c1">=</span><span class="pl-c1">1.0</span>)

<span class="pl-s1">ds</span> <span class="pl-c1">=</span> <span class="pl-s1">sns</span>.<span class="pl-en">load_dataset</span>(<span class="pl-s">'iris'</span>)
<span class="pl-s1">grid</span> <span class="pl-c1">=</span> <span class="pl-s1">sns</span>.<span class="pl-en">pairplot</span>(<span class="pl-s1">ds</span>)
<span class="pl-s1">grid</span>.<span class="pl-en">map_offdiag</span>(<span class="pl-s1">plot_unity</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'test.png'</span>)</pre></div>
<p dir="auto">But the image produced doesn't show the off-diagonal lines present in the linked answer:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6620652/97183604-e2f1de80-1795-11eb-96fe-5c7cc47c8296.png"><img src="https://user-images.githubusercontent.com/6620652/97183604-e2f1de80-1795-11eb-96fe-5c7cc47c8296.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Package versions are the latest releases:<br>
Matplotlib 3.3.2<br>
seaborn 0.11.0<br>
Python 3.6.5</p>
<p dir="auto">I am running on Windows and get the same output from the REPL, iPython and Jupyter Lab.</p>
<p dir="auto">Thanks for a great library!</p>
<p dir="auto">Hi,</p>
<p dir="auto">I discovered that the map_* methods of PairGrid seem to be broken in version 0.11.0 for user defined functions. See reproducible example below with a corrfunc defined to plot the pearson correlation value on the lower plots. The function doesn't seem to get evaluated in version 0.11.0. When I pip install seaborn==0.10.1, I get the desired result. Plots from both cases also attached.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy import stats
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style=&quot;white&quot;)

mean = np.zeros(3)
cov = np.random.uniform(.2, .4, (3, 3))
cov += cov.T
cov[np.diag_indices(3)] = 1
data = np.random.multivariate_normal(mean, cov, 100)
df = pd.DataFrame(data, columns=[&quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;])

def corrfunc(x, y,**kws):
    r, _ = stats.pearsonr(x, y)
    ax = plt.gca()
    ax.annotate(&quot;r = {:.2f}&quot;.format(r),
                xy=(.1, .9), xycoords=ax.transAxes)

g = sns.PairGrid(df, palette=[&quot;red&quot;])
g.map_upper(plt.scatter, s=10)
g.map_diag(sns.distplot, kde=False)
g.map_lower(sns.kdeplot, cmap=&quot;Blues_d&quot;)
g.map_lower(corrfunc)
plt.show()
"><pre lang="import" class="notranslate"><code class="notranslate">from scipy import stats
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white")

mean = np.zeros(3)
cov = np.random.uniform(.2, .4, (3, 3))
cov += cov.T
cov[np.diag_indices(3)] = 1
data = np.random.multivariate_normal(mean, cov, 100)
df = pd.DataFrame(data, columns=["X", "Y", "Z"])

def corrfunc(x, y,**kws):
    r, _ = stats.pearsonr(x, y)
    ax = plt.gca()
    ax.annotate("r = {:.2f}".format(r),
                xy=(.1, .9), xycoords=ax.transAxes)

g = sns.PairGrid(df, palette=["red"])
g.map_upper(plt.scatter, s=10)
g.map_diag(sns.distplot, kde=False)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_lower(corrfunc)
plt.show()

</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/3239171/94969718-380d3e00-04d1-11eb-821b-9aad80ec696e.png"><img src="https://user-images.githubusercontent.com/3239171/94969718-380d3e00-04d1-11eb-821b-9aad80ec696e.png" alt="seaborn-0-11-0" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/3239171/94969722-3a6f9800-04d1-11eb-8ef1-861d9beb1f26.png"><img src="https://user-images.githubusercontent.com/3239171/94969722-3a6f9800-04d1-11eb-8ef1-861d9beb1f26.png" alt="seaborn-0-10-1" style="max-width: 100%;"></a></p>