Is it possible to create a selective legend in a multiplot graph?
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I already asked this question in somewhat less clear manner. So now I added a clear code:
I have two sets of data - A_Data and B_Data.
In each set the data has a data ID. So I have A_IDs and B_IDs.
I plot all on the same axis:
% Prepare:
H = My_Axis;
Num_Of_A = length(A_IDs);
Num_Of_B = length(B_IDs);
Lgnd_Cell = cell(Num_Of_A+Num_Of_B,1);
Lgnd_Indx = true(Num_Of_A+Num_Of_B,1)
% Plot A data:
for i = 1:Num_Of_A
Data = Data_A{i};
plot3(H,Data(:,1),Data(:,2),Data(:,3),['Certain_Shape' 'Certain_Color']);
hold on;
Lgnd_Cell{i} = ['A Data ' num2str(A_IDs(i))];
Lgnd_Indx(i) = Determine_If_To_Show_This_Data_Legend(Data);
end
% Plot B data:
for i = 1:Num_Of_B
Data = Data_B{i};
plot3(H,Data(:,1),Data(:,2),Data(:,3),['Certain_Shape' 'Certain_Color']);
hold on;
Lgnd_Cell{Num_Of_A+i} = ['A Data ' num2str(B_IDs(i))];
Lgnd_Indx(Num_Of_A+i) = Determine_If_To_Show_This_Data_Legend(Data);
end
Now, based on 'Lgnd_Indx' I want to create a selective legend.
Is it possible?
Thanks,
Alon
回答(1 个)
Walter Roberson
2018-12-31
record the handles returned by plot3. Index them by your Indx array as your first parameter to legend and index the cell by the same as your second parameter to legend
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!