How can I hold the previous "legend" on a plot?
古いコメントを表示
I use the "hold" function to hold the previous plots. But how can I hold the previous legends, too?
採用された回答
その他の回答 (3 件)
Gerd
2011 年 6 月 14 日
For example I you would like to show the sin and cos you would use
t=[0:0.1:10]
x=sin(t)
y=cos(t)
plot(t,x)
hold
plot(t,y,'r')
legend('sin','cos')
In your case you have to build the legendstring with the two different "strings" you want to show.
Gerd
2011 年 6 月 14 日
Hi sadel, to get the current legend use
% you have to have a legend on the current plot
get(legend(gca),'String'); % get legend from current axes.
% Now you can set the legend of the new plot
Gerd
5 件のコメント
sadel
2011 年 6 月 14 日
Gerd
2011 年 6 月 14 日
Hi sadel, what do you mean by having a 2 lines legend?
Do you want to have 2 plots with 2 legend?
Gerd
sadel
2011 年 6 月 14 日
Rajani Metri
2020 年 12 月 5 日
Hello,
but legend holding only text. It is showing legend indicators as lines, instead of asteric lines, which I used. It is not holding the marking points of plots. For holding Marker points of respective plots, what to do?
Thank You.
Walter Roberson
2020 年 12 月 5 日
Which MATLAB version are you using? And please explain what you are trying to do in more detail?
Andrea Cavallini
2018 年 2 月 6 日
0 投票
Quick and dirty... at last (before hold off), draw something out of the scope of the plot, but with the right legend symbols. That will do
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
