Label multiple boxplots in same figure

I used this code to create a figure with two boxplots. How do I label K and M (on x-axis) as "HC" and "SZ" respectively?? I also would like to name the y-axis "Kurtosis." Thanks in advance!
toget=[K M];
grp=[zeros(1,21),ones(1,19)];
boxplot(toget,grp)

 Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 11 de Jun. de 2019
Editada: KALYAN ACHARJYA el 11 de Jun. de 2019
As you didnot provided the K and M, so I did not able to cehck my code, this is perfectly works on bar charts, please try and let me know, it working or not?
x_label= {'HC';'SZ'};
toget=[K M];
grp=[zeros(1,21),ones(1,19)];
boxplot(toget,grp)
set(gca,'xticklabel',x_label)
or
boxplot([toget,grp],'Labels',{'HC','SZ'})

4 comentarios

aet
aet el 11 de Jun. de 2019
Yes! This worked. How do I add a y-axis label?
KALYAN ACHARJYA
KALYAN ACHARJYA el 11 de Jun. de 2019
Try with 'yticklabel'?
aet
aet el 11 de Jun. de 2019
I don't want the y ticks, I just want the entire axis labeled
aet
aet el 11 de Jun. de 2019
I figured it out. Used ylabel('Kurtosis') and it gave me what I wanted

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

aet
el 11 de Jun. de 2019

Comentada:

aet
el 11 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by