So... the problem i see is that the characteristics of the markers are linked directly to the style of the plotted points. So far i cannot find a way to directly edit the legend handles to change the marker color. However through knowing how legend generates the items you can "trick" it. From my guess your implementation of the legend is to just go legend('series 1','series 2','blah blah blah... ',...,'location', 'southoutside');
well when that happens you're grabbing the first 3 plotted objects. so knowing that why don't we plot specific points outside the plotted area? such as the code below does. I colored the legend markers magenta just to show that i have full control over what happens in the legend. Also if you un-comment the threshold point at 5 you'll see that the first marker would be then the ---- and everything has been shifted over.
clc, clear all; close all;
x = 1:10
y = randi(10,1,10);
hfig = figure;
hold on
markers ='oxdoxdoxdoxdoxdoxdoxd';
umarkers = unique(markers,'stable');
for ind = 1:length(umarkers)
plot(-10,-10,['m' umarkers(ind)])
end
for ind = 1:10
if y(ind) <5
plot(x(ind),y(ind),[markers(ind) 'r']);
else
plot(x(ind),y(ind),[markers(ind) 'b']);
end
end
ylim([0 10])
xlim([0 10]);
legend('circle','X-mark','diamond');
plot([0 10],[5 5],'k--');
If i think of a cleaner way to do this i'll repost it.
0 Comments
Sign in to comment.