I have a scatterplot where the points are colored by group number. How do I add a legend with the group color attached?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a scatter plot with each point colored by it's cluster number (ranging from 1 to 5) and I'm trying to add a legend that will indicate which color belongs to which group.
scatter(Data.X, Data.Y, Data.ClusterNumber); legend(strcat('Group: ', num2str(transpose(1:5))))
The above gets me the scatter plot and legend, but there is only a single dot for all 5 clusters.
댓글 수: 0
채택된 답변
Star Strider
2018년 1월 26일
If you have the Statistics and Machine Learning Toolbox, it is probably easier to use the gscatter (link) function.
댓글 수: 2
추가 답변 (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!