Colour points in 2d or 3d based on value of another vector
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Elliot Ferguson
le 30 Août 2022
Commenté : Elliot Ferguson
le 30 Août 2022
I have several parallel vectors of data and I have been plotting them against each other in various ways to determine relationships and develop a model. One thing I would like to do is make a plot with each point coloured based on a further quantity, namely temperature. I have tried experimenting with colormap functions but haven't yet managed to find a satisfactory compact solution.
Something similar to this is what I am going for, it seems much simpler to do with matplotlib.
The temperatures range from roughly 40-100 so 40 should be classed as 'cold' and at the blue end, etc. I am looking for a solution for both 2d and 3d plots as I will be working with both of these.
0 commentaires
Réponse acceptée
Cris LaPierre
le 30 Août 2022
Modifié(e) : Cris LaPierre
le 30 Août 2022
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(40,100,length(x));
scatter(x,y,[],c,'filled')
colormap jet
colorbar
You could follow a similar approach using scatter3. The only difference is specifying X,Y and Z. You can find some examples here.
figure
z = cos(x) + rand(1,200);
scatter3(x,y,z,[],c,'filled')
colormap jet
colorbar
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Colormaps 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!