changing the axis of a plot in a way that the data series starts at x=0 at a point at one point on the y-axis and ends on the right end of the plot
이전 댓글 표시
hi,
I have this code:
dates=datenum(VIXdate)
y=VIX
plot(dates,y)
%datevc divides the date in different columns, first colum is the year,
%second the month and thrid the day
d=datevec(dates)
%Takes just the year (first column)
d=d(:,1)
%takes every year just once
[a,idx]=unique(d(:,1),'first')
ylabel('VIX');
set(gca,'xtick',dates(idx),'xticklabel',a)
set(gca,'Box','off')
this works fine, but the problem I faces is that the time series (y=VIX) does not start at the left end of the plot but instead there is a space between the y-axis and the first point of the time series. I know that when there are normal values on the x-axis, I can change it, but I am not able to do it with dates, what do I need to do?
댓글 수: 1
Babak
2013년 4월 29일
Undefined function or variable 'VIXdate'.
채택된 답변
추가 답변 (2개)
Mel
2013년 5월 1일
You could also set just the x axis to be the same as your data:
xlim([0 max(dates)])
Jonathan Epperl
2013년 4월 29일
axis tight
댓글 수: 3
Locks
2013년 5월 1일
Jonathan Epperl
2013년 5월 1일
Sure. Without knowing what your actual data looks like (it would still be nice if you could post a working minimal example), you could do that:
ylims = get(gca,'YLim');
axis tight
set(gca,'YLim',ylims);
Dirty, but should work.
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!