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
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.

采纳的回答

David Hill
David Hill 2020-12-2
sz=25;
scatter(A(:,4),A(:,3),sz,A(:,1),'filled');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by