フィルターのクリア

Bypass a Line Plotted in the Legend

1 回表示 (過去 30 日間)
Dima
Dima 2012 年 2 月 4 日
Hello!)
I wonder how do I bypass a line plot out of multiple plots when putting the legend on a chart.
Suppose I have 10 vectors plotted on a chart. If I wish to make the legend display the info for only the first 3 time series and only for the last one...how do I do that?
leg = legend('one','two','three','four','five','six','seven','eight','nine','ten','Location','SouthEast');
Thanks!
Dima

回答 (2 件)

Bjorn Gustavsson
Bjorn Gustavsson 2012 年 2 月 4 日
If you call plot with an output argument:
ph = plot(randn(10));
You can select which lines to have in the legend:
legend(ph([1:3,end]),'1','2,'3','432')
HTH
  2 件のコメント
Dima
Dima 2012 年 2 月 4 日
YES)) but what if I have plotline for various functions put on one chart and I only want to have the legend for some of them?
Bjorn Gustavsson
Bjorn Gustavsson 2012 年 2 月 5 日
ph(1) = plot(x1,y1);
ph(2:3) = plot(x2,[y2;y3]);
...
ph(10) = plot(x12,y12);
legend as above.
Or you could store the plot-handles in cell arrays to store the plot handles.
legend([ph1{1}(2),ph{2}([4,3]),...],...)
HTH

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


Walter Roberson
Walter Roberson 2012 年 2 月 5 日

カテゴリ

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