
Is it possible to manipulate the line sample the legend shows
1 回表示 (過去 30 日間)
古いコメントを表示
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'})
0 件のコメント
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!