Plot lower triangle in a seaborn Pairgrid
With seaborn >= 0.9.1:
import seaborn as sns
iris = sns.load_dataset("iris")
sns.pairplot(iris, corner=True)
this is basically the same as the accepted answer, but uses the official methods from seaborn.PairGrid
:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="ticks")
iris = sns.load_dataset("iris")
def hide_current_axis(*args, **kwds):
plt.gca().set_visible(False)
g = sns.pairplot(iris)
g.map_upper(hide_current_axis)
hiding the lower half is also easy:
g.map_lower(hide_current_axis)
or hiding the diagonal:
g.map_diag(hide_current_axis)
alternatively, just use the PairGrid
directly for more control:
g = sns.PairGrid(iris, hue='species', diag_sharey=False)
g.map_lower(sns.scatterplot, alpha=0.3, edgecolor='none')
g.map_diag(sns.histplot, multiple="stack", element="step")
g.map_upper(hide_current_axis)
which gives:
Since Seaborn 0.9.1 there has been a corner=True
setting, allowing the above to be changed to:
import seaborn as sns
iris = sns.load_dataset("iris")
sns.pairplot(
iris, hue='species', corner=True,
plot_kws=dict(alpha=0.3, edgecolor='none'),
diag_kind="hist",
diag_kws=dict(multiple="stack", edgecolor='none'),
)