I'm using Seaborn's pairplot:
g = sns.pairplot(df)
Is it possible to draw identity lines on each of the scatter plots?
Define a function which will plot the identity line on the current axes, and apply it to the off-diagonal axes of the grid using PairGrid.map_offdiag()
method.
For example:
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)
This makes the following plot on my setup. You can tweak the kwargs of the plot_unity
function to style the plot however you want.