Bar with descending data
1 回表示 (過去 30 日間)
古いコメントを表示
Rachele Franceschini
2021 年 10 月 21 日
回答済み: Cris LaPierre
2021 年 10 月 22 日
I have this bar. But I would like the data in descending order.
How can I do? Help me!
This is "my" script
data100 = readtable(filename100,'TextType','string');
% taking first 10 words.
data100 = data100 (1:10,:);
data100.Word = categorical (data100.Word);
%figure with italian words
figure
bar(data100.Word, data100.Count);
xlabel("Word");
ylabel("Class Distribution");
0 件のコメント
採用された回答
Cris LaPierre
2021 年 10 月 22 日
Because your data is categorical, it is getting plotted in alphabetical order by default. You can change the order using reordercats (see this answer).
You can maybe do this programmatically doing something like this (untested):
[~,idx] = sort(data100.Count,'descend');
C = categories(data100.Word);
data100.Word = reordercats(data100.Word,C(idx));
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Categorical Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!