Plotting multiple Box plots on a single figure for multiple conditions

2 views (last 30 days)
Hi,
I currently have a data set structured with 4 columns (C) and 15 rows (in this example). C1 and C2 are the categories in this case C1 = subject & C2 = task.
All 5 subjects performed 3 different tasks. and from that we recorded 2 variables C3,C4 are my variables of interest.
I would like to create a boxplot for C3, C4 using each of the 5 subject data points under the 3 categories in C2 ('Task1', 'Task2', 'Task3')
I currently can only either create individual figures for each task or get the plots to overlap each other and not display side by side.
The example data end result should be something like below.

Answers (1)

Ayush Gupta
Ayush Gupta on 31 Aug 2020
This can be achieved using the hold on command along with the polyshape function in MATLAB. Suppose the vertices for task 1 are x1 = [C31 C32 C33 C34 C35] an y1= [C41 C42 C43 C44 C45]. Here C31 refers to the first value of C3 corresponding to Task1 and similarly for C41.
pgon1 = polyshape(x1,y1);
pgon2= polyshape(x2,y2);
plot(pgon) ;
hold on
plot(pgon2);
This can be continued for the next tasks and the desired plot can be obtained. For example, on how to use the polyshape functions and some examples on how to use it, refer the documentation.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!