フィルターのクリア

How to dynamicly change the tick order for xticklabels

5 ビュー (過去 30 日間)
Katy Weihrich
Katy Weihrich 2020 年 4 月 28 日
コメント済み: Adam Danz 2020 年 4 月 28 日
I am trying to do a graphic where I compaire multiple groups by creating a scatter plot where the hue of the dot corresponding to the effect size between compairisons. I need to run the compairisons for different features on the data groups, therefore I want to sort the groups dynamicly by the mean for each feature in the graphic.
I labeled the x- and y-axis such as:
yticks([1:25])
yticklabels({'Heel Up','Heel Dw', ...
'Flat Up','Flat Dw','Swing Heel', ...
'Swing Flat', ... .......
});
where 1 = 'Heel Up', 2 = 'Heel Dw', ect.
For the new graph I already changed the order of the plots by creating the variable
label_neworder = [10,12,19,2,23,4,11,15,17,18,9,3,8,21,22,20,1,13,5,16,14,6,7]; % for example
I tried resorting the labels using categorical,
x_tick_labels = categorical(label_neworder,[1:25], ...
{'Heel Up','Heel Dw', ...
'Flat Up','Flat Dw','Swing Heel', ...
'Swing Flat', ... .......
})
but when I try to apply it I only get the error message:
xticklabels(x_tick_labels_cat);
% Error using xticklabels (line 43)
% Specify tick labels as cell array of character vectors, string array, or one of the 'mode', 'auto', or 'manual' options.
I would need to reformat "x_tick_labels", but I cannot quite figure out how to do so.

採用された回答

Adam Danz
Adam Danz 2020 年 4 月 28 日
編集済み: Adam Danz 2020 年 4 月 28 日
tickLabels = {'Heel Up','Heel Dw', ...
'Flat Up','Flat Dw','Swing Heel', ...
'Swing Flat', ... .......
};
yticklabels(tickLabels(label_neworder));
  2 件のコメント
Katy Weihrich
Katy Weihrich 2020 年 4 月 28 日
Now that I am seeing it, it is pretty obvious!
Thank you very much!
Adam Danz
Adam Danz 2020 年 4 月 28 日
That happens to the best of us!
Glad I could help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by