legend('G1','G2')
The line style shown for both entries is the same. Is there anyway - to manually change this after the plots have been generated ? I am looking for a way to do this within the code itself. I have the LineSpec for each group before plotting.
Regards,
-A
% Setup
x = 1:10;
h = zeros(1, 5);
axis([0 11 0 51])
linestyles = {'-', ':','-.','--',':'};
hold on
% Create 5 lines and store their handles
for k = 1:5
h(k) = plot(x, k*x, linestyles{k});
end
% Create the legend -- lines 2 and 5 should have the same line style
legend(h)
% Change line 2's LineStyle and both the plot and the legend will update
set(h(2), 'LineStyle', '-')
--
Steve Lord
sl...@mathworks.com
plot(x,y,'b*') will plot blue for b and *
plot(x,y,'r-','linewidth',4) will plot a thick red dashed line
type help plot for more options
the legend will account for these changes
however, I think i was not clear in my question. So here is another attempt:
consider the following:
----------------------------------------
k1=1:5;k2=6:10;
jj=rand(10,10);
for i=1:10
if(~isempty(find(k1==i)))
plot(sort(rand(10,1)),'-+');
else
plot(sort(rand(10,1)),':');
end
hold on
end
legend('S1','S2')
-----------------------------------
Running the above snippet - will show 10 curves, divided into TWO types of line styles. however the Legend shows two entries with the SAME line style. I would like to change the legend to highlight the two different types of lines being used to plot.
(As a workaround right now I am plotting the the first series from each group, adding the legend and then plotting the rest of each group - but i think there has to be a more elegant way of doing this..)
thanks again..