Effacer les filtres
Effacer les filtres

How to remove fixed xlabels from bar plots?

20 vues (au cours des 30 derniers jours)
Inti Vanmechelen
Inti Vanmechelen le 2 Juil 2019
Commenté : Star Strider le 2 Juil 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!

Réponse acceptée

Star Strider
Star Strider le 2 Juil 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 commentaires
Inti Vanmechelen
Inti Vanmechelen le 2 Juil 2019
Easy as it is...
Thank you!
Star Strider
Star Strider le 2 Juil 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by