title: Obtaining values used in boxplot, using python and matplotlib
body: <p>I can draw a boxplot from data:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  data = np.random.rand(100)
  plt.boxplot(data)
  </code></pre>
  
  <p>Then, the box will range from the 25th-percentile to 75th-percentile, and the whisker will range from the smallest value to the largest value between (<code>25th-percentile - 1.5*IQR, 75th-percentile + 1.5*IQR</code>), where the IQR denotes the inter-quartile range. (Of course, the value 1.5 is customizable).</p>
  
  <p>Now I want to know the values used in the boxplot, i.e. the median, upper and lower quartile, the upper whisker end point and the lower whisker end point. While the former three are easy to obtain by using <code>np.median()</code> and <code>np.percentile()</code>, the end point of the whiskers will require some verbose coding:</p>
  
  <pre><code>median = np.median(data)
  upper_quartile = np.percentile(data, 75)
  lower_quartile = np.percentile(data, 25)
  
  iqr = upper_quartile - lower_quartile
  upper_whisker = data[data&lt;=upper_quartile+1.5*iqr].max()
  lower_whisker = data[data&gt;=lower_quartile-1.5*iqr].min()
  </code></pre>
  
  <p>I was wondering, while this is acceptable, would there be a neater way to do this? It seems that the values should be ready to pull-out from the boxplot, as it's already drawn.</p>