Reputation:
This figure (fig_1) is a pairwise scatter plot on iris dataset. The diagonal plots the marginal histograms of the 4 features.
I am trying to reproduce this figure with Python.
here is the code
>>> import numpy as np, pandas as pd; np.random.seed(0)
>>> import seaborn as sns; sns.set(style="white", color_codes=True)
>>> iris = sns.load_dataset("iris")
>>> g = sns.pairplot(iris, vars = iris.columns[0:4] , diag_kind = 'hist')
the output (fig_2) is
How to set the color of the dots except for the main diagonal, shown as the fig_1?
I've also tried hue
option which colors the main diagonal as well, that's why I said "except for the main diagonal".
Upvotes: 0
Views: 616
Reputation: 812
Try this, sns.pairplot(iris,hue="species",diag_kws=dict(color="b"))
.
The diag_kws applies the values to only the diagonal plots
Upvotes: 1
Reputation: 150785
Based on @ImportanceOfBeingErnest comment:
g = sns.PairGrid(iris)
g = g.map_diag(plt.hist)
g = g.map_offdiag(sns.scatterplot, hue=iris['species'])
Output:
Upvotes: 0