title: How to locate the median in a (seaborn) KDE plot?
body: <p>I am trying to do a <a href="http://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.kdeplot.html" rel="noreferrer">Kernel Density Estimation (KDE) plot</a> with seaborn and locate the median. The code looks something like this: </p>
  
  <pre><code>import seaborn as sns
  import numpy as np
  import matplotlib.pyplot as plt
  
  sns.set_palette("hls", 1)
  data = np.random.randn(30)
  sns.kdeplot(data, shade=True)
  
  # x_median, y_median = magic_function()
  # plt.vlines(x_median, 0, y_median)
  
  plt.show()
  </code></pre>
  
  <p>As you can see I need a <code>magic_function()</code> to fetch the median x and y values from the <code>kdeplot</code>. Then I would like to plot them with e.g. <code>vlines</code>. However, I can't figure out how to do that. The result should look something like this (obviously the black median bar is wrong here):</p>
  
  <p><img src="https://i.stack.imgur.com/tOD7G.png" alt="enter image description here"></p>
  
  <p>I guess my question is not strictly related to seaborn and also applies to other kinds of matplotlib plots. Any ideas are greatly appreciated.</p>