Add number of data points to gscatter() legend
이전 댓글 표시
I have a set of data points I am plotting using gscatter(). All the points classified as "Type1" plot as blue circles, "Type2" plot as green circles, etc. I'd like the legend to also show the number of points in each dataset (e.g., 'Type1, n=7'). These data points are in the "screened_data" table in the code below. There are other things that I'm also plotting that I don't want in the legend (i.e., I don't want "data2" or the line plot to be in the legend). Thanks in advance for any clever (or obvious) ideas!
data2 = scatter(selected.x, selected.y, 300, 'pentagram', 'MarkerEdgeColor', 'black', 'MarkerFaceColor', 'white');
n = max(screened_data.nTypes);
C = hsv(n);
data1 = gscatter(screened_data.x, screened_data.y, screened_data.Type, C);
xmin = 3;
xmax = 300;
ymin = 8;
ymax = 200;
xlim([xmin xmax])
ylim([ymin ymax])
plot([xmin xmax], [32 32], 'Color', 'black')
text(xmin+0.1, 31.5, 'Lable for 32', 'FontSize', 6);
lgnd = legend([data1], 'Location', 'eastoutside');
lgnd.FontSize = 8;
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
