Make Y-axis show percentage of values, highest value to be set as 100%.

8 次查看(过去 30 天)
How can I get my values in y to be represented in percent according to the highest value in y on a bar plot?
Incomplete code:
y = [10.6, 6.4, 5.2, 5.2, 6.3, 14.3, 19.0, 22.3, 22.5, 25.9...
26.5, 25.1, 24.3, 24.6, 23.9, 23.6, 23.2, 24.6, 22.7, 23.4...
26.2, 26.6, 25.1, 22.9];
m = max(y);
bar(y)
set(gca, 'XTick', [1:1:24], 'XTickLabel', rem([0:1:23],24))

采纳的回答

David Fletcher
David Fletcher 2021-4-15
y = [10.6, 6.4, 5.2, 5.2, 6.3, 14.3, 19.0, 22.3, 22.5, 25.9...
26.5, 25.1, 24.3, 24.6, 23.9, 23.6, 23.2, 24.6, 22.7, 23.4...
26.2, 26.6, 25.1, 22.9];
m = max(y);
yPc=y/m*100
bar(yPc)
set(gca, 'XTick', [1:1:24], 'XTickLabel', rem([0:1:23],24))
  1 个评论
Rudolf
Rudolf 2021-4-20
Thanks for the math. :) Got the percentage sign added by using code from the last answer in this post: https://www.mathworks.com/matlabcentral/answers/390402-how-to-change-y-axis-label-with-percentage

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by