1

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.Picture Sample

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Daniel Poh
  • 129
  • 1
  • 10

1 Answers1

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)

enter image description here

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