How to remove space from beginning of a plot?

조회 수: 3 (최근 30일)
Anwesha Sharma
Anwesha Sharma 2023년 2월 13일
편집: Anwesha Sharma 2023년 2월 14일
I have a plot with monthly data over multiple years, but there is a space in front of the plot that I would like to remove and start the X-axis limit from January (i.e., Jan Feb Mar Apr Oct Nov Dec).
T=table(datestr(Temp6ONDJFMAcorrect.DATE,'dd/mm/yyyy'),Temp6ONDJFMAcorrect.Temp);
[y,m,d] = datevec(T.Var1,'dd/mm/yyyy');
Tdate = table(y,m,d,'VariableName',{'year','month','day'});
TT = [Tdate,T(:,{'Var2'})];
TT.Properties.VariableNames{4} = 'Temp'; yrs = TT.year;
yr = ismember(str2double(string(TT.year)),yrs);
x = reshape(TT.month(yr),7,[]);
y = reshape(TT.Temp(yr),7,[]);
plot(x,y)
xticklabels({'Jan', 'Feb', 'Mar','Apr','Oct','Nov','Dec'})
  댓글 수: 4
Image Analyst
Image Analyst 2023년 2월 13일
So is the missing line
Temp6ONDJFMA = readtable('Temp6ONDJFMA.xls'); % Read workbook file into a MATLAB table variable.
??? Anyway, it looks like you've accepted an answer so I guess it doesn't matter anymore since you've gotten a solution.
Anwesha Sharma
Anwesha Sharma 2023년 2월 14일
It's still not working, if I use 'axis tight' or xlim([1 12]), the January from the x axis disappears.

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

답변 (1개)

Alexander Halbleib
Alexander Halbleib 2023년 2월 13일
편집: Alexander Halbleib 2023년 2월 13일
you may be able to try:
xlim([1,12]);
at the end of your file.
If I'm reading your code properly, your axes should be numeric, so this version should work.
  댓글 수: 1
Anwesha Sharma
Anwesha Sharma 2023년 2월 14일
편집: Anwesha Sharma 2023년 2월 14일
So sorry, I had to unaccept the answer, it is still not working. The January from x-axis disappears

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by