How to plot two columns of a repeated value column from the same matrix?
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!