Creating legend for scatter plot
古いコメントを表示
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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!