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 日

0 投票

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 月 26 日
Thank you very much!
Star Strider
Star Strider 2019 年 8 月 26 日
As always, my pleasure!
Lilya
Lilya 2019 年 8 月 29 日
May I ask for extra help ? :$
I get lost when I tried to apply the same code to obtain the same attached figure.
could you please help me with that?
I do appreciate it.
Star Strider
Star Strider 2019 年 8 月 29 日
I will do my best.
My best guess is that you would need to do something like this for multiple timelines:
plot(North', ones(size(North'))*k, '-b', 'LineWidth', 5);
where ‘k’ is the y-value where you want to plot them.
As always, my pleasure.
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 日

0 投票

I want to create plot like this

カテゴリ

タグ

質問済み:

2019 年 8 月 25 日

回答済み:

2020 年 2 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by