How to plot two columns of a repeated value column from the same matrix?
조회 수: 1 (최근 30일)
이전 댓글 표시
if A is a 10x4 matrix with some repeated values along A(:,1) like:
A=[1 10 13 31
1 15 33 22
1 43 3 12
1 3 54 12
2 45 34 13
2 44 31 12
2 32 35 11
3 34 13 31
3 34 34 12
4 35 23 43];
I want to plot scatter(A(:,4),A(:,3)) with the same dot color for every value of A(:,1) that is repeated. For instance a manual plot of A would be:
scatter(A(1:4,4),A(1:4,3),'filled','r')
hold on
scatter(A(5:7,4),A(5:7,3),'filled','b')
hold on
scatter(A(8:9,4),A(8:9,3),'filled','k')
hold on
scatter(A(10,4),A(10,3),'filled','g')
Which plots
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/440773/image.png)
I used manually the colors red, blue, black and green for the first 4 repeated values. But to analize a big dataset, i would like to plot the scatter using a colorbar for the increasing A(:,1) repeated values.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!