MATLAB Answers

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

9 views (last 30 days)
ANKITA MAITY
ANKITA MAITY on 26 Sep 2021 at 19:49
Answered: Dave B on 27 Sep 2021 at 0:00
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 at 0:00
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by