Plot of 4 variables with dates(years)

조회 수: 1 (최근 30일)
Andreas S
Andreas S 2020년 10월 10일
편집: Abdolkarim Mohammadi 2020년 10월 11일
Hello everyone! I need some help on a plot. I need to put in a plot 4 cumulative returns(CS1,CS2,CS3,SC4) on axe y, with variable date 1990,1993,1996,2000,2003,2006,2010,2013,2016 and 2020 on axe x for four strategies P1,P2,P3,P4.
ylabel({'Cumulative return'});
xlabel({'Date'});
title({'Cumulative returns of the portfolios'});
Legend({'P1','P2','P3','P4'});

채택된 답변

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 10월 10일
편집: Abdolkarim Mohammadi 2020년 10월 11일
You should read the documentation of plot():
All you need is to define cumulative return of the four series in columns.
CumulativeReturn = [
5 4 1 6
14 9 4 16
26 17 14 31
40 34 29 55
61 59 52 80
66 63 53 86
75 68 56 96
87 76 66 111
101 93 81 135
122 118 104 160];
Years = [1990;1993;1996;2000;2003;2006;2010;2013;2016;2020];
PlotHandle = plot (Years, CumulativeReturn);
set (PlotHandle, {'DisplayName'}, {'P1';'P2';'P3';'P4'});
set (PlotHandle, {'LineWidth'}, {2;2;2;2});
xlabel ('Years');
xticks (Years);
ylabel ('Cumulative return');
title ('Cumulative returns of the portfolios');
legend ('Location', 'Northwest');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by