How can I change bar graph x-axis?
70 ビュー (過去 30 日間)
Hello, I want to order my bar graph (left hand side) in descending order but didn't succeed in ordering x-axis labels (right hand side). Values in x-axis are feature indices. How can I fix it? Thanks for the help.
[a,b] = sort(Scores_Avg,2,'descend')
text(1:length(a), a', num2str(a','%0.3f'),...
dpb 2021 年 8 月 11 日
編集済み: dpb 2021 年 8 月 11 日
[a,ia] = sort(Scores_Avg,2,'descend'); % use more meaningful index variable
bar(a) % plot the sorted array vs linear order
xticks(1:numel(a)) % set the tick marks to match bar number
xticklabels(ia) % label x ticks to go with sorted order
You need to first also set xticks to the full number of bins if there are enough bars that the default tick marks don't put that many tick marks on the axes.
NB: the caveat in the comment below -- as N grows, space starts to get very dear...