How to plot two columns of a repeated value column from the same matrix?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Philippe Corner
le 2 Déc 2020
Réponse apportée : David Hill
le 2 Déc 2020
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 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!