How could I change the axis for a boxplot that is automatically produced from ANOVA test?

28 views (last 30 days)
How could I change the axis on my boxplot? I did a ANOVA test and a box-plot was automatically produced. I have 3 groups for my analysis. By default, the group was labelled as 1, 2, 3 accordingly. I would like to change it to A, B, C.
I have tried to do something like this (see below), but it did not work.
boxplot([x1,x2],'Notch','on','Labels',{'A','B','C'})

Accepted Answer

Ive J
Ive J on 20 Dec 2020
You can set XTickLabel property of the generated boxplot.
mydata = randn(20, 3);
anova1(mydata);
set(gca, 'XTickLabel', {'A', 'B', 'C'}) % the last gca is the boxplot by default.
Alternatively, use group argument of anova1:
mydata = rand(1, 60);
group = repmat({'A', 'B', 'C'}, 1, 20);
anova1(mydata, group)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!