Borrar filtros
Borrar filtros

how to write this xlabel like in this example?

1 visualización (últimos 30 días)
benghenia aek
benghenia aek el 20 de Mzo. de 2021
Comentada: Star Strider el 20 de Mzo. de 2021
Please can anyone show me how to add the xlable (A-OSA; A-N; C-N) like the example below?
exemple:
y = [316.45 292.14 319.96; 305.59 287.99 295.21;316.45 292.14 319.96; 305.59 287.99 295.21;...];
316.45 292.14 319.96; 305.59 287.99 295.21;316.45 292.14 319.96; 305.59 287.99 295.21;305.59 287.99 295.21]
box on
bar(y)
set(gca,'xticklabel',{'Pre-test'; 'Post-test';'Pre-test'; 'Post-test'})
ylim([200 360])
ylabel('RT (ms)')
xticks([1 2 3 4 5 6 7 8 9])
xticklabels({'knn','svm','dt','knn','svm','dt','knn','svm','dt'});

Respuestas (1)

Star Strider
Star Strider el 20 de Mzo. de 2021
Try adding this to the end of theposted code:
text(xt(2:3:end), 188*ones(1,3), {'A-OSA','A-N','C-N'}, 'horiz','center', 'vert','top')
so the full code is now:
y = [316.45 292.14 319.96; 305.59 287.99 295.21;316.45 292.14 319.96; 305.59 287.99 295.21;...
316.45 292.14 319.96; 305.59 287.99 295.21;316.45 292.14 319.96; 305.59 287.99 295.21;305.59 287.99 295.21];
box on
hbar = bar(y);
set(gca,'xticklabel',{'Pre-test'; 'Post-test';'Pre-test'; 'Post-test'})
ylim([200 360])
ylabel('RT (ms)')
xticks([1 2 3 4 5 6 7 8 9])
xticklabels({'knn','svm','dt','knn','svm','dt','knn','svm','dt'});
xt = get(gca, 'XTick');
text(xt(2:3:end), 188*ones(1,3), {'A-OSA','A-N','C-N'}, 'horiz','center', 'vert','top')
Experiment with it to get the result you want.
  2 comentarios
benghenia aek
benghenia aek el 20 de Mzo. de 2021
Thank you so much Mr Star Strider
Star Strider
Star Strider el 20 de Mzo. de 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by