How do I create two legends in one GScatter Plot?
10 ビュー (過去 30 日間)
古いコメントを表示
Hi,
so I have two gscatter plots in one figure and I would like to add a a legend for each of the plots. So the problem is, that the first legend is filled with the entries of the second legend at the end. Can someone help me?
Thanks a lot.
figure();
hold on
gs1 = gscatter(data(:,1),data(:,2),target,[],[],20);
leg1 = legend(gs1, 'Location','NorthEastOutside');
title(leg1,'Data1')
gs2 = gscatter(data(:,3),data(:,4),target,[],'o',5);
a=axes('position',get(gca,'position'),'visible','off');
leg2 = legend(a, gs2, 'Location','EastOutside');
title(leg2,'Data2')
0 件のコメント
回答 (1 件)
G A
2020 年 8 月 5 日
Rearrange your code in the following sequence:
figure();
clf
hold on
gs1 = gscatter(data(:,1),data(:,2),target,[],[],20);
gs2 = gscatter(data(:,3),data(:,4),target,[],'o',5);
a1=gca;
a2=axes('position',get(gca,'position'),'visible','off');
leg1 = legend(a1, gs1, 'Location','NorthEastOutside');
leg2 = legend(a2, gs2, 'Location','EastOutside');
title(leg1,'Data1');
title(leg2,'Data2');
hold off
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!