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

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

 Risposta accettata

michio
michio il 20 Gen 2020

2 voti

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

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

Accedi per commentare.

Più risposte (0)

Richiesto:

il 20 Gen 2020

Commentato:

il 20 Gen 2020

Community Treasure Hunt

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

Start Hunting!