How to control appearance of certain graphs legend in a multi graph plot?
    4 views (last 30 days)
  
       Show older comments
    
Hi all,
I have the following code which produce a multi fraph plot on an axes which I identify as 'H'
Legend_Data = cell(Some_Number); 
for i = 1:Some_Number
   plot3(H,X,Y,Z,[Marker,Color]); 
   Legend_Data{i} = 'Some text';
end
'H' is the axes (in a GUI) in which I want to plot all the graphs. 
In each iteration the vectors X,Y,Z are different as well as the sting 'Some text'. Also, the marker used for the graph and its color are changed. 
At the end, based on some logic, I wand to desplay a legend but to exclude some of entries. Of course, I want the remaining data to be correctly associated with the right graphs. 
I read some sugesstions over the net but couldn't figure out how to apply them to this code. Most of them were related to cases where all graphs are ploted at once. 
Can it be done?
Thanks in advance,
Alon 
Answers (1)
  madhan ravi
      
      
 on 19 Dec 2018
        Comment reposted as answer:
x=rand(10,5);
y=rand(10,5);
z=rand(10,5);
h=cell(1,5);
c={'a','b','c','d','e'};
for i = 1:5
   h{i}=plot3(x(:,i),y(:,i),z(:,i));
   hold on
end
legend([h{1} h{3} h{5}],c{1},c{3},c{5})
3 Comments
  madhan ravi
      
      
 on 19 Dec 2018
				
      Edited: madhan ravi
      
      
 on 19 Dec 2018
  
			can you give an example of your legend contents so that the solution can be narrowed down ?
See Also
Categories
				Find more on Legend in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
