Borrar filtros
Borrar filtros

How to remove fixed xlabels from bar plots?

20 visualizaciones (últimos 30 días)
Inti Vanmechelen
Inti Vanmechelen el 2 de Jul. de 2019
Comentada: Star Strider el 2 de Jul. de 2019
Hi,
I have a bar plot in which matlab automatically calls the two things I gave as an input as "one" and "two", but these are not the xlabels I want. (I want the "test" "retest", which is now under the 1 & 2)
Any idea how to remove these?
This is the (short) code and the bar plot is in attachment
figure();
suptitle('IMU power distribution: Acc Z');
EVENTPOWER1 = [POWER.H1.RF3(k).event(2).PZ POWER.H1.RF3(k).event(3).PZ POWER.H1.RF3(k).event(4).PZ; ...
RT_POWER.H1.RF1(k).event(2).PZ RT_POWER.H1.RF1(k).event(3).PZ RT_POWER.H1.RF1(k).event(3).PZ];
EVP = subplot(1,2,1);
bar(EVP,EVENTPOWER1);
xlabel(['Test Retest',newline,'subject 1'])
EVENTPOWER2 = [POWER.H2.RF3(k).event(2).PZ POWER.H2.RF3(k).event(3).PZ POWER.H2.RF3(k).event(4).PZ; ...
RT_POWER.H2.RF1(k).event(2).PZ RT_POWER.H2.RF1(k).event(3).PZ RT_POWER.H2.RF1(k).event(3).PZ];
EVP2 = subplot(1,2,2);
bar(EVP2,EVENTPOWER2);
xlabel(['Test Retest',newline,'subject 2'])
Thanks in advance!

Respuesta aceptada

Star Strider
Star Strider el 2 de Jul. de 2019
You need to use the axis 'XTickLabel' property to change the numbers into the labels you want.
Try this:
X = rand(2,3);
figure
bar(X)
set(gca, 'XTickLabel',{'Test','Retest'})
xlabel('Subject 1')
Depending on your MATLAB version, you might also need to specify the 'XTick' values:
X = rand(2,3);
figure
bar(X)
set(gca, 'XTick',[1 2], 'XTickLabel',{'Test','Retest'})
xlabel('Subject 1')
Make appropriate changes to work with your code.
  2 comentarios
Inti Vanmechelen
Inti Vanmechelen el 2 de Jul. de 2019
Easy as it is...
Thank you!
Star Strider
Star Strider el 2 de Jul. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by