Azzera filtri
Azzera filtri

how to write this xlabel like in this example?

2 visualizzazioni (ultimi 30 giorni)
benghenia aek
benghenia aek il 20 Mar 2021
Commentato: Star Strider il 20 Mar 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'});

Risposte (1)

Star Strider
Star Strider il 20 Mar 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 Commenti
Star Strider
Star Strider il 20 Mar 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by