5

Given the following sample script:

import seaborn as sns
import pandas as pd
import numpy as np
# Generate some random multivariate data
x, y = np.random.RandomState(8).multivariate_normal([0, 0], [(1, 0), (0, 1)], 1000).T
# Add to a dataframe
df = pd.DataFrame({"x":x,"y":y})
# Plot
p = sns.jointplot(data=df,x='x', y='y',kind='kde')

...Which gives the following plot:

enter image description here

How might I go about finding the location on the x and y axis where the density is greatest?

I would like to annotate the most dense region of the centre plot and have spent a while searching the attributes of each plot, but nothing seems to stand out. I though that it might be as easy as getting the max y-axis value for e.g. the top KDE plot, and the max x-axis value of the right-hand side KDE plot but has so far not been easy to find.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Dman2
  • 700
  • 4
  • 10

0 Answers0