I want to remove the blank space between the first two bars and the last two bars. Can anyone help please?

조회 수: 1(최근 30일)
I want to remove the blank space in the middle of this figure. Can anyone help please?
This is my code:
figure(30)
x1=T_Smooth{1:4,8};
M1=[T_Smooth{1,5} T_Smooth{1,7}; T_Smooth{2,5} T_Smooth{2,7};T_Smooth{3,5} T_Smooth{3,7};T_Smooth{4,5} T_Smooth{4,7}];
timetoadd1=[T_Smooth{1,9};T_Smooth{2,9};T_Smooth{3,9};T_Smooth{4,9}];
timetoadd2=[T_Smooth{1,11};T_Smooth{2,11};T_Smooth{3,11};T_Smooth{4,11}];
h1=bar(x1,M1,1);
xtips1=h1(1).XEndPoints;
ytips1=h1(1).YEndPoints;
labels1=string(timetoadd1);
text(xtips1,ytips1,labels1,'HorizontalAlignment','center','VerticalAlignment','bottom')
xtips2=h1(2).XEndPoints;
ytips2=h1(2).YEndPoints;
labels2=string(timetoadd2);
text(xtips2,ytips2,labels2,'HorizontalAlignment','center','VerticalAlignment','bottom')
xlabel('Date/Time of the sample')
ylabel('Peak value of concentration (nmol/l)')
ylim([0 130])
legend({'Melatonin','Cortisol'},'Location','northwest')
title('Maximum melatonin & cortisol concentration for participant 1')
This is the figure I mean:
  댓글 수: 3

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

채택된 답변

the cyclist
the cyclist 2021년 9월 14일
Instead of using the dates in x1 to define the bar positions along the X axis, you could use
h1=bar(M1); % instead of h1=bar(x1,M1);
which will create evenly spaced bars along the X axis.
Then label the X ticks with the date:
set(gca,'XTickLabel',{'Apr 24','Apr 25','May 1','May 2'})

추가 답변(0개)

범주

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by