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?
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.
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With