Is it possible to colour a scatter3 according to its mean and maximum value

1 view (last 30 days)
i have velocities distributed in a 3d scatter plot along a cosine hill prrofile . i want to view where the velocity is increasing and where it is decresing its value.

Answers (1)

Dave B
Dave B on 27 Sep 2021
You can color the points in a scatter3 by passing in a vector specifying the value you'd like to map onto color as the 5th argument to scatter3
[xi,yi]=meshgrid(1:30,1:30);
zi=gausswin(30)*gausswin(30)';
[fx,fy]=gradient(zi);
nexttile
ci=zi;
scatter3(xi(:),yi(:),zi(:),10,ci(:),'filled')
colorbar
nexttile
ci=fx;
scatter3(xi(:),yi(:),zi(:),10,ci(:),'filled')
colorbar
nexttile
ci=fy;
scatter3(xi(:),yi(:),zi(:),10,ci(:),'filled')
colorbar
nexttile
ci=sqrt(fx.^2+fy.^2);
scatter3(xi(:),yi(:),zi(:),10,ci(:),'filled')
colorbar
colormap turbo

Categories

Find more on Colormaps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!