How to remove fixed xlabels from bar plots?

조회 수: 40 (최근 30일)
Inti Vanmechelen
Inti Vanmechelen 2019년 7월 2일
댓글: Star Strider 2019년 7월 2일
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.
  댓글 수: 2
Inti Vanmechelen
Inti Vanmechelen 2019년 7월 2일
Easy as it is...
Thank you!
Star Strider
Star Strider 2019년 7월 2일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (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