필터 지우기
필터 지우기

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 CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by