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

11 visualizaciones (últimos 30 días)
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))

Respuesta aceptada

David Fletcher
David Fletcher el 15 de Abr. de 2021
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 comentario
Rudolf
Rudolf el 20 de Abr. de 2021
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

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by