How to edit scatter plot legend?
17 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a problem changing the color of markers for my legend.
I made the scatter plots separately with different size and color of the markers (see attachment), towards the end I use the following:
for k1 = 1:length(A)
scatter(A(k1),B(k1), 50, 'r', 'filled')
end
hold on
legend ('Living single corals','Living coral thicket', 'Basaltic boulders','Basaltic cobbles','Coarse sands', 'Ripples', 'Coral debris', 'Hardground slab')
xlabel('Distance, m');
ylabel('Depth, m')
set (gca,'FontSize',14)
hold on
I would like the legend to be the same as in the plot, however, the legend came up to be just one size and one color.
Appreciate your help.
Thank you,
Sara
0 件のコメント
回答 (1 件)
Walter Roberson
2019 年 5 月 21 日
Every scatter call generates a graphics object and by default legend draws labels by order of graphics object.
2 件のコメント
Walter Roberson
2019 年 5 月 21 日
That scatter in a loop can be replaced with a single scatter call
scatter(A, B, 'k', 'filled')
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!