Is it possible to manipulate the line sample the legend shows

조회 수: 1 (최근 30일)
Jesse Velay-Vitow
Jesse Velay-Vitow 2019년 11월 5일
답변: Vashist Hegde 2021년 3월 25일
I am plotting data, as well as the moving mean of that data and I would like it if the legend would show a sample of the mean over top of the data as seen here: ,rather than showing the data and its mean as separate entries on the legend. I'm not sure that this is possible, and my backup is to just edit it in using GIMP. I appreciate any help, or info that this is infact not doable.
Here's some simple code I've been using to test this out:
test=zeros(100,1);
test1=zeros(100,1);
for i=1:50
test(2*i)=.3;
end
for i=1:50
test1(2*i)=.3;
end
test=test+1;
test1=test1+10;
testmean=movmean(test,20);
test1mean=movmean(test1,20);
figure;
hold on
h1=plot(test1);
h2=plot(test);
h3=plot(test1mean,'r-','LineWidth',2);
h4=plot(testmean,'b-','LineWidth',2);
legend([h3 h4],{'Test1 mean', 'Test mean'})

답변 (1개)

Vashist Hegde
Vashist Hegde 2021년 3월 25일
DISCLAIMER: These are my own views and in no way depict those of MathWorks.
Hi Jesse,
I understand that you want to reflect in your legend.
But the issue is that currently the legend method is designed to accept separate graphic objects and show them separately in the legend. Unfortunately there is no provision to combine two different lines and reflect them as one in the legend.
So the best bet to solve your problem would be to edit it using GIMP.
Hope this helps.

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by