Note that there was a way in https://tutorialmore.com/questions-1150768.htm.
import seaborn as sns
import matplotlib.pyplot as plt
def hide_current_axis(*args, **kwds):
plt.gca().set_visible(False)
#Data frame preparation
X = sns.load_dataset("iris")
#Pair plot
pg = sns.pairplot(X)
#Erase the upper graph = display the lower triangular part
pg.map_upper(hide_current_axis)
#Erase the graph below = Display the upper triangle
# pg.map_lower(hide_current_axis)
#Erase the diagonal part
# pg.map_diag(hide_current_axis)
Or place your favorite graph in any position with pairgrid.
from itertools import groupby
import seaborn as sns
import matplotlib.pyplot as plt
def hide_current_axis(*args, **kwds):
plt.gca().set_visible(False)
def stackedhist(data, stackby, **kwds):
groups = groupby(zip(stackby, data), lambda x: x[0])
grouped_data = [[v for _, v in items] for key, items in groups]
plt.hist(grouped_data, stacked=True, edgecolor='none')
#Data frame preparation
X = sns.load_dataset("iris")
g = sns.PairGrid(X, diag_sharey=False)
g.map_lower(sns.scatterplot, data=X, hue='species', alpha=0.3, edgecolor='none')
g.map_diag(stackedhist, stackby=X['species'])
g.map_upper(hide_current_axis)
Recommended Posts