Tuesday, September 16, 2014

Skip items in Matlab legend


You can specify a vector of plot handles to use in the legend. For example:

h1 = plot(rand(1,10));      % Blue line
hold on;
h2 = plot(rand(1,10),'r');  % Red line
h3 = plot(rand(1,10),'g');  % Green line
legend([h1 h3],{'hello','world'});  % Only the blue and green lines appear
                                    %   in the legend

No comments:

Post a Comment