フィルターのクリア

x-axis on plot has cushion to left and right (i.e. plot doesn't start at beginning, and ends early with remaining space in the chart

2 ビュー (過去 30 日間)
Here is my code:
startDate=datenum(num2str(tday(1)),'yyyymmdd');
endDate=datenum(num2str(tday(end)),'yyyymmdd');
cumret=cumprod(1+combinedRet)-1;
x=linspace(startDate,endDate,length(cumret));
plot(x,cumret);
ax=gca;
datetick('x',2,'keepticks');
ax.XTickLabelRotation=45;
My start date and end date are 8/24/12 - 5/29/15. So why does the x-axis start at 5/11/12 and end at 8/24/15?
Also, how can I increase the number of dates shown on the x-axis?
Many thanks, I am very grateful.

採用された回答

dpb
dpb 2015 年 6 月 6 日
datetick unless told differently via keeplimits uses an internal rounding alogrithm to pick the axes limits to make what it considers "nice" intervals and number of ticks.
If you want something specific for start and end then use
xlim([datenum(firstDate) datenum(lastDate)])
to set those limits specifically before calling datetick
You can set the tick marks as desired with
set(gca,'xtick',_datenumSequence_)
where datenumSequence is a series of datenums at the spacing you wish beginning and ending with the above axes limits.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by