カテゴリカル データをもつ棒グラフの作成(https://jp.mathworks.com/help/matlab/ref/bar.html)
を参考に棒グラフを作成しているのですが,棒グラフの並び順をアルファベット順意外(カテゴリ配列順)にしたいです.
どのようにすれば良いでしょうか?

 채택된 답변

michio
michio 2020년 1월 20일

2 개 추천

例えばこういう例ですね。
c = categorical({'apples','pears','oranges'});
prices = [1.23 0.99 2.3];
bar(c,prices)
untitled1.png
これはカテゴリ型配列を作る際に順序を指定しておけば入力の順序で表示されます。
c = categorical({'apples','pears','oranges'},{'apples','pears','oranges'},'Ordinal',true);
prices = [1.23 0.99 2.3];
bar(c,prices)
untitled1.png

댓글 수: 2

Teppei Iwata
Teppei Iwata 2020년 1월 20일
Barのほうではなく,カテゴリのほうに順序を表すオプションがあったんですね...
無事解決いたしました,ありがとうございました.
michio
michio 2020년 1월 20일
お役に立てて幸いです。確かに bar の方にも欲しいですね。

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

질문:

2020년 1월 20일

댓글:

2020년 1월 20일

Community Treasure Hunt

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

Start Hunting!