Plotting a 3D scalar field as a coloured 3D scatter graph

66 views (last 30 days)
I have a 3D temperature data set: a 3D array giving the temperature at each point in a 3D cartesian space, with coordinates x, y, z. I would like to find a way of visualising this data set. I thought it would be straightforward to plot a 3D scatter graph, and at each point on the graph the temperature is represented by a colour. However, I'm not sure how to use the scatter3 function.
Can anyone please help me to plot this data?
Specifically my data is:
x=linspace(-0.3,0.3,16); y=linspace(-0.3,0.3,16); z=linspace(-0.3,0.3,16);
Then I have a 3D array, Temperature(x,y,z) which has a different value for each set x,y,z.

Accepted Answer

Patrick Kalita
Patrick Kalita on 2 May 2012
Edited: John Kelly on 27 May 2014
If you want to use scatter3, you can pass it your x, y, and z vectors which will define where markers will be drawn. Then your temperature data can be used to control the size and/or color of the markers. According to your description, x, y, and z are vectors whereas Temperature is a 3D array. That seems slightly odd, but I suppose plausible. At any rate, you'd need to at least convert that 3D array into a vector before passing it to scatter3:
scatter3( x, y, z, [], Temperature(:) ); % Use Temperature to set marker color
That makes some assumptions about how the data is actually stored, but it's a best guess based on the information you've given.
If you have a lot of data points, then scatter3 isn't the best option.
wendy wang
wendy wang on 4 Feb 2015
Edited: wendy wang on 4 Feb 2015
Hi Paul, I took the suggestion to visualize my data with scatter3. I have (x, y, z, P) data set, where x, y ,z are coordiantes with size of 1*N. P is the parameter at the corresponding location and it also has the size of 1*N. I can successfully visualize my data using scatter3, but can not do the slice plot. How do you do the slice plot for such case with scatter data? It looks like the slice function only apply to 3-D array of x, y,z and P. Can I do it in a 1-D array?
By the way, I have a lot of data points, besides the scatter3, is there any other better idea to visualize the data in 3D space with color indicating the P parameter? Thanks for any advice!!

Sign in to comment.

More Answers (1)

uri iger
uri iger on 7 Aug 2018
Hi! so if I have about 14M points, what do I use?
Thanks a lot! Uri

Community Treasure Hunt

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

Start Hunting!

Translated by