I want to implement a 5 number summary along the diagonal of a Python Seaborn PairGrid. I tried df.describe() along the diagonal but it did not work. A sample of what I am looking for is the picture at the bottom of this link (https://towardsdatascience.com/visualizing-data-with-pair-plots-in-python-f228cf529166), which is also pasted here for convenience.
Asked
Active
Viewed 248 times
1

Trenton McKinney
- 56,955
- 33
- 144
- 158

Daniel Poh
- 129
- 1
- 10
-
1Have you looked into his github code in https://github.com/WillKoehrsen/Data-Analysis/blob/master/pairplots/Pair%20Plots.ipynb ? – Dwight Aug 24 '20 at 07:15
-
I didnt notice he posted his github address there thanks. – Daniel Poh Aug 24 '20 at 09:47
1 Answers
2
This is fairly straightforward using PairGrid
and a custom plotting function for the diagonal:
def print_stats(data, **kwargs):
data = pd.Series(data)
ax = plt.gca()
ax.annotate(data.describe().to_string(), xy=(0.5,0.5), xycoords='axes fraction', ha='center', va='center')
iris = sns.load_dataset("iris")
g = sns.PairGrid(iris)
g = g.map_lower(plt.scatter)
g = g.map_diag(print_stats)

Diziet Asahi
- 38,379
- 7
- 60
- 75