How to remove fixed xlabels from bar plots?

20 次查看(过去 30 天)
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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by