How to skip the legends for some series of data that's actually Null after some Calculation?
Show older comments
Hello, everyone. Here is the problem I am facing. Say I have 3 series of data, but some of the series could be of length 0. As I plotted them all on the same figure, I want to legend them correctly, how should I do that more compactly? Below is what I got ( notice the data are all in the structure Performance)
if cellfun('isempty', Performance.Apple)
legend('Orange', 'Banana');
elseif cellfun('isempty', Performance.Orange)
legend('Banana', 'Orange');
elseif cellfun('isempty', Performance.Banana)
legend('Apple', 'Orange');
elseif cellfun('isempty', Performance.Apple) & cellfun('isempty', Performance.Orange)
legend('Banana');
elseif cellfun('isempty', Performance.Apple) & cellfun('isempty', Performance.Banana)
legend('Orange');
elseif cellfun('isempty', Performance.Orange) & cellfun('isempty', Performance.Banana)
legend('Apple');
end
So you get what I'm trying to do, right? I know there must be a trick to do these smartly, please help me.
Answers (1)
Categories
Find more on Line Plots 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!