Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Box plot with min, max, average and standard deviation

Tags:

I need to create a box plot with results for some runs - for each of these runs I have the minimum output, maximum output, average output and standard deviation. This means that I will need 16 boxplots with labels.

The examples I ran into so far plot a numerical distribution, but in my case, this is not feasible.

Is there any way to do this in Python (Matplotlib) / R?

like image 488
Crista23 Avatar asked Oct 25 '15 10:10

Crista23


People also ask

Can you make a boxplot with mean and standard deviation?

If we don't have whole data but mean and standard deviation are available then the boxplot can be created by finding all the limits of a boxplot using mean as a measure of central tendency.

How do you plot standard deviation on a box plot?

In a somewhat similar fashion you can estimate the standard deviation based on the box plot: the standard deviation is approximately equal to the range / 4. the standard deviation is approximately equal to 3/4 * IQR.

What is max and min in the boxplot?

The far left of the chart (at the end of the left “whisker”) is the minimum (the smallest number in the set) and the far right is the maximum (the largest number in the set). Finally, the median is represented by a vertical bar in the center of the box. Box plots aren't used that much in real life.

How can you tell which standard deviation is higher on a box plot?

Boxplot II likely has the data with the larger standard deviation because the boxplot appears to have a greater​ spread, which likely results in a larger standard deviation.


1 Answers

The answer given by @Roland above is important: a box plot shows fundamentally different quantities, and if you make a similar plot using the quantities you have, it might confuse users. I might represent this information using stacked errorbar plots. For example:

import matplotlib.pyplot as plt import numpy as np  # construct some data like what you have: x = np.random.randn(100, 8) mins = x.min(0) maxes = x.max(0) means = x.mean(0) std = x.std(0)  # create stacked errorbars: plt.errorbar(np.arange(8), means, std, fmt='ok', lw=3) plt.errorbar(np.arange(8), means, [means - mins, maxes - means],              fmt='.k', ecolor='gray', lw=1) plt.xlim(-1, 8) 

enter image description here

like image 196
jakevdp Avatar answered Oct 13 '22 22:10

jakevdp