How can I add a vertical line at the x-location in which y is on its maximum in a seaborn dist plot?
import seaborn as sns, numpy as np
sns.set(); np.random.seed(0)
x = np.random.randn(5000)
ax = sns.distplot(x, kde = False)
PS_ In the example above, we know that it's probably going to pick at 0
. I am interested to know how I can find this value in general, for any given distribution of x.
This is one way to get a more accurate point. First get the smooth distribution function, use it to extract the maxima, and then remove it.
Edit Alternate solution without using
kde=True
This results in the actual distribution and not the density values