How to control appearance of certain graphs legend in a multi graph plot?
1 次查看(过去 30 天)
显示 更早的评论
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
7 个评论
回答(1 个)
madhan ravi
2018-12-19
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 个评论
madhan ravi
2018-12-19
编辑:madhan ravi
2018-12-19
can you give an example of your legend contents so that the solution can be narrowed down ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!