What exactly does a Boxplot show? [duplicate]

This question already has an answer here:

Having a Boxplot like the following, how do I read it? marked as duplicate by Firebug, Martin Thoma, Community♦Apr 11 '17 at 13:14

• @Firebug Ah, right. I didn't find that. – Martin Thoma Apr 11 '17 at 13:14

The colored block (orange and green) shows where 50% of the data are. The lower boundary is the 25-percentile, the upper boundary is the 75-percentile. The line in the middle is the mean.

The distance between the 75-percentile and the 25-percentile is called "interquartile range" (IQR). 1.5 times the IQR from the 25-percentile border is the lower whisker (the vertical line at 161cm for human and 122cm for ape). Everything lower than that is an outlier and only represented by a dot. The same for the upper whisker.

You can make such plots like this:

#!/usr/bin/env python

import seaborn as sns
import random
import operator as op
import numpy as np

data = {}
names = [('human', 174, 5), ('ape', 150, 10)]
for name, mu, sigma in names:
trial = []
trial_length = random.randint(200, 500)

for _ in range(trial_length):
trial.append(random.randint(0, 1000))
# data.append(trial)
data[name] = list(np.random.normal(mu, sigma, trial_length))

for key, values in data.items():
print(key)
p025 = np.percentile(values, 25)
p075 = np.percentile(values, 75)
p_dist = p075 - p025
print("\t[{}, {}]".format(p025, p075))
print("\tlower whisker: {}".format(p025 - p_dist * 1.5))
print("\tupper whisker: {}".format(p075 + p_dist * 1.5))

sorted_keys, sorted_vals = zip(*sorted(data.items(), key=op.itemgetter(1)))

ax = sns.boxplot(data=sorted_vals, orient="h", palette="Set2")
# category labels
sns.plt.yticks(sns.plt.yticks(), sorted_keys)
ax.set(xlabel='Size in cm')
sns.plt.savefig("fig.png")