Change the scale of a horizontal bar graph

31 visualizaciones (últimos 30 días)
iLikeMatlab
iLikeMatlab el 25 de Ag. de 2019
Comentada: Star Strider el 25 de Ag. de 2019
Hi everyone, I would like to know how I can normalize , I don't know if it is the correct word, the x-axis of a horizontal bar graph (barh).
More specifically, I have calculated some coefficients which sum to 1 hence each of them can be expressed as a % . Therefore, instead of getting an automatic max value on the x-axis of the barh, I would like to change this in order to display values like 10,20,30,......,100 being the max value.
Thank you very much in advance.

Respuesta aceptada

Star Strider
Star Strider el 25 de Ag. de 2019
I am not certain what you currently are seeing, or what you want.
Try this:
v = [0.1 0.3 0.2 0.4]; % Create Data
figure
barh(v)
xlim([0 1]) % Set X-Axis Limits
xt = get(gca, 'XTick'); % Current X-Tick Values
set(gca, 'XTick',xt, 'XTickLabel',xt*100) % New X-Tick Values
  2 comentarios
iLikeMatlab
iLikeMatlab el 25 de Ag. de 2019
Such an acccurate answer!
Thank you so much Star Strider. However, in my case I multiplied the v vector:
v = v.*100;
and then I just set the xlim to :
xlim([0 100]);
and everything is scaled perfectly.
Thank you again.
Star Strider
Star Strider el 25 de Ag. de 2019
Thank you!
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by