필터 지우기
필터 지우기

datatip for timeseries plot with date string

조회 수: 2 (최근 30일)
ThorBarra
ThorBarra 2011년 10월 17일
I have a time series where the date is given by a date string. I'd like to use the data tip to find specific events on the plot. How would I have to modify the text update function so that the x-axis is given as readable date? Or what format has the x-axis when a timesieries is plotted with absolute dates in the time.
thanks.t.

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 10월 17일
Hi,
I guess by "absolute dates" you mean something like
ts = timeseries(rand(12,1), datenum(2011, 1:12, 1));
plot(ts);
datetick('x', 'mm/yyyy')
If this is the case:
dcm = datacursormode(gcf);
dcm.Enable = 'on';
dcm.UpdateFcn = @myupdate;
and save the following code to myupdate.m:
function txt = myupdate(src, event)
pos = get(event,'Position');
txt = {['Date: ' datestr(pos(1), 'dd.mm.yyyy')], ...
['Value: ' num2str(pos(2))]};
Titus

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by