Borrar filtros
Borrar filtros

Bypass a Line Plotted in the Legend

1 visualización (últimos 30 días)
Dima
Dima el 4 de Feb. de 2012
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

Respuestas (2)

Bjorn Gustavsson
Bjorn Gustavsson el 4 de Feb. de 2012
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 comentarios
Dima
Dima el 4 de Feb. de 2012
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 el 5 de Feb. de 2012
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

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 5 de Feb. de 2012

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by