How to remove fixed xlabels from bar plots?

20 views (last 30 days)
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!

Accepted Answer

Star Strider
Star Strider on 2 Jul 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.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!