Hello
I have created a scatter plot in the following way:
arousal = [1, 9, 2, 5, 6, 8, 3, 2]; correctness = [1, 0, 1, 1, 1, 0, 0, 0]; type = {'type1', 'type1', 'type3', 'type2', 'type3', 'type1', 'type2', 'type1'}; plot(arousal, 'k'); hold on; for i = 1:length(arousal) switch type{i} case 'type1' color = 'r'; case 'type2' color = 'g'; case 'type3' color = 'b'; end if correctness(i) marker = 'o'; scatter(i, arousal(i), 90, color, marker, 'filled'); else marker = 'o'; scatter(i, arousal(i), 90, color, marker, 'LineWidth', 2); end end
I'm using three different colors for the markers. The markers can either be filled or not.
Now I would like to create a legend containing the three different colors as well as explaining filled and not filled markers. For red color it should be written "type1" in the legend, for green color "type2" and for blue color "type3". Moreover, for a filled circle it should be written "correct" and for not filled "incorrect". The filled and not filled circles could for example drawn in black in the legend.
How can this be done?
Best Answer