フィルターのクリア

Why is only one tick mark displayed when using datetick?

5 ビュー (過去 30 日間)
Bruno Rodriguez
Bruno Rodriguez 2017 年 3 月 14 日
コメント済み: Bruno Rodriguez 2017 年 3 月 14 日
I have a simple timeseries plot for which I am using datetick to label the x-axis in the format DD/mm as my times are in datenum format. However, after applying datetick, only the first tick mark shows up. I cannot get the later dates to appear. Any ideas? Code below, data attached.
data = load('data.mat');
times = data.times;
rh = data.rh;
plot(times,rh)
datetick('x','DD/mm','keeplimits')

採用された回答

Chad Greene
Chad Greene 2017 年 3 月 14 日
That's because datetick is a bit clunky, and it can't get a lock on a date that it thinks is worthy of displaying. Probably because your date range is somewhat short. For example, here's a year of data:
t = datenum(2005,1,1:365);
y = sind(t);
plot(t,y,'bo-')
datetick('x','DD/mm','keeplimits')
But if you only have 5 days of data it can't find a good match:
t = datenum(2005,1,1:5);
y = sind(t);
plot(t,y,'bo-')
datetick('x','DD/mm','keeplimits')
But you can specify xticks manually. Let's set an x tick every other day:
set(gca,'xtick',t(1:2:end))
datetick('x','DD/mm','keepticks','keeplimits')
  1 件のコメント
Bruno Rodriguez
Bruno Rodriguez 2017 年 3 月 14 日
Ah, makes sense. Manually it is then. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by