Question

I've seen a lot of solutions to create boxplots on one plot side by side, but of all these solutions require that all the vectors in the set have the same number of data points. How do you put boxplots on the same plot but with different amounts of data points?

Was it helpful?

Solution

If you have data in a vector X, which you want to be plotted in several boxplots, create a new vector G, the same size as X with a 1 for the first boxplot, 2 for the second, etc.

For example, you want to plot a boxplot for 1 2 3 4 5 6 and another for 7 8 9 10.

X=[1 2 3 4 5 6 7 8 9 10];
G=[1 1 1 1 1 1 2 2 2 2];
boxplot(X,G)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top