I have a large data set form wich I want to plot quite some graphs, 105 to be exacly. In these graphs a maximum of 4 lines is plotted but not in every graph. I have added a maker and a line color so that they are easy to diffentiate for eachother. I want to add a legend to these so that you can see which line is what. The legend however get, I think, overruled when a new line is added and if I add the legend at the end of my code it wil not refer to te right line if not all the 4 lines are in the graph. Is it possible to create a legend based on the linecolor of on the marker?
if Config_num(a,1) ~= Configuration(c-1,1) && Config_num(a,1) == Configuration(c,1) n= sum(Configuration == Config_num(a,1)); plot(Fn(c:c+n-1,1),Rel_rest(c:c+n-1,1),'-bo') T = {'Lp/Bpx =' LpBpx(c,1) , 'Ap/\Nabla =' ApNabla23Rounded(c,1) , 'LCG =' LCG(c,1)}; legend('\beta = 12.5', 'Location', 'northwest'); title(T) elseif Config_num(a,2) ~= Configuration(c-1,1) && Config_num(a,2) == Configuration(c,1) n= sum(Configuration == Config_num(a,2)); plot(Fn(c:c+n-1,1),Rel_rest(c:c+n-1,1),'-rx') legend('\beta = 19', 'Location', 'northwest'); title(T) elseif Config_num(a,3) ~= Configuration(c-1,1) && Config_num(a,3) == Configuration(c,1) n= sum(Configuration == Config_num(a,3)); plot(Fn(c:c+n-1,1),Rel_rest(c:c+n-1,1),'-cs') legend('\beta = 25', 'Location', 'northwest'); title(T) elseif Config_num(a,4) ~= Configuration(c-1,1) && Config_num(a,4) == Configuration(c,1) n= sum(Configuration == Config_num(a,4)); plot(Fn(c:c+n-1,1),Rel_rest(c:c+n-1,1),'-m^') legend ('\beta = 30', 'Location', 'northwest'); title(T) end
Best Answer