I have some code that basically does this:
for i = 1:length(ReliabilityStruct)
if (FailureFlags(i) == 0)
plot(X(i), Y(i), '.b');
elseif (FailureFlags(i) == 1)
plot(X(i), Y(i), 'or');
elseif (FailureFlags(i) == 2)
plot(X(i), Y(i), 'og');
elseif (FailureFlags(i) == 3)
plot(X(i), Y(i), 'ok');
else
fprintf('\nUnknown Flag, check Data\n')
return
end
end
drawnow;
legend('Recovery', '1', '2', '3');
So my aim is to make a graph that has different symbols for different flags. See below:

As you can see, the Legend doesn’t exactly fit the data. How can you change each of the legend entries to fix this up? Alternatively, is there a better way to approach this?
I think you can use something like this (added bonus is that you avoid loops!):