how to write this xlabel like in this example?
2 ビュー (過去 30 日間)
古いコメントを表示
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'});
0 件のコメント
回答 (1 件)
Star Strider
2021 年 3 月 20 日
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 件のコメント
Star Strider
2021 年 3 月 20 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!