Remove "data1" & "data2" recession plot legend

I'm plotting a return series with a recession plot as an overlay. The issue is that the recession "bars" shows up as data1 and data2 in the legend.
How do I remove "data1" & "data2" from the legend?
clear
clc
v = datevec({'31-Jan-2000','31-May-2021'});
date = datenum(cumsum([v(1,1:3);ones(diff(v(:,1:3))*[12 1 0 ]',1)*[0 1 0 ]]));
x=randn(257,1);
figure;
plot(date,x);
datetick('x','yyyy');
legend('x');
recessionplot;

 채택된 답변

the cyclist
the cyclist 2021년 8월 25일
The simplest is probably to just wait until all the plots are created before adding the legend.
v = datevec({'31-Jan-2000','31-May-2021'});
date = datenum(cumsum([v(1,1:3);ones(diff(v(:,1:3))*[12 1 0 ]',1)*[0 1 0 ]]));
x=randn(257,1);
figure;
plot(date,x);
datetick('x','yyyy');
recessionplot;
legend('x')

댓글 수: 1

Niko
Niko 2023년 5월 31일
Worked perfectly, thanks! This is the answer I needed.

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

추가 답변 (0개)

카테고리

질문:

2021년 8월 25일

댓글:

2023년 5월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by