棒グラフの並び順について

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

 Accepted Answer

michio
michio on 20 Jan 2020

2 votes

例えばこういう例ですね。
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 Comments

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

Sign in to comment.

More Answers (0)

Asked:

on 20 Jan 2020

Commented:

on 20 Jan 2020

Community Treasure Hunt

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

Start Hunting!