How to add a legend to an existing plot?

3 ビュー (過去 30 日間)
Del
Del 2013 年 1 月 24 日
I have a figure and it has 2 curves. When I add the legend from the 'insert menu', it only shows data1 and data2. I don't think that's enough information for my figure. So I would like to edit the legend but it won't let me. I read somewhere that it is possible to add a legend. But I am not sure how to do it for an Existing plot. So for instance, let say my figure's name is Error_vs_points, the first curve is is a solid line, the second curve is a dashed line. And I would like to add a legend that says: 'solid line': Error vs PointsA; 'Dashed line': Error vs PointsB.
Any idea?

採用された回答

Del
Del 2013 年 1 月 24 日
ok, now what if I already have the figure, called Error_vs_points.fig , but I want to add a legend to it?
  3 件のコメント
Del
Del 2013 年 1 月 24 日
Thanks!
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 24 日
Why have you accepted your answer which is in fact a question?

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 24 日
編集済み: Azzi Abdelmalek 2013 年 1 月 24 日
t=0:0.1:10;
y1=sin(t);
y2=cos(t);
plot(t,y1,'-g',t,y2,'--r')
legend({'y1','y2'})

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by