필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Rudolf
Rudolf 2021년 4월 15일
댓글: Rudolf 2021년 4월 20일
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