how to create timeline plot?

조회 수: 104 (최근 30일)
Lilya
Lilya 2019년 8월 25일
답변: Farhan ul haq 2020년 2월 11일
Hi all,
I want to create a timeline plot similer to the following:
North | |||||||||||||||||||||||||||| |||||||||||||||||||||||||||||
|
|
Central | ||||||||||||||||||||||||||||||||||
|_________________________________________
Jan Feb Mar Apr .....etc
start date end date start date end date
the time periods for the north are datenum([2019 01 30]) datenum([2019 04 12], and datenum(2019,07,03) datenum(2019,08,25)
Time for the Central is datenum(2019,01,08) datenum(2019,03,03)
Any help will be appreciated
Thanks.

채택된 답변

Star Strider
Star Strider 2019년 8월 25일
Try this:
North = [datenum([2019 01 30]), datenum([2019 04 12]); datenum(2019,07,03) datenum(2019,08,25)];
Central = [datenum(2019,01,08) datenum(2019,03,03)];
figure
plot(North', ones(2)*2, '-b', 'LineWidth', 5);
hold on
plot(Central, [1 1], '-r', 'LineWidth',5)
hold off
ylim([0 3])
datetick('x', 'mmm')
set(gca, 'YTick',[1 2], 'YTickLabel',{'Central','North'})
There are also other options, for example using the patch function. It depends on what you want to do.
  댓글 수: 6
Lilya
Lilya 2019년 8월 29일
Thanks like a bunch!
Star Strider
Star Strider 2019년 8월 29일
As always, my pleasure!

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

추가 답변 (1개)

Farhan ul haq
Farhan ul haq 2020년 2월 11일

I want to create plot like this

카테고리

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