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

30 visualizaciones (últimos 30 días)
Paul
Paul el 1 de Mayo de 2012
Respondida: uri iger el 7 de Ag. de 2018
Hello,
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.
Thanks.

Respuesta aceptada

Patrick Kalita
Patrick Kalita el 2 de Mayo de 2012
Editada: John Kelly el 27 de Mayo de 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.
  2 comentarios
Paul
Paul el 3 de Mayo de 2012
Thank you very much Patrick - you're right that all I had to do was convert the temperature from an array. The temperature (which I have called A) is a 3D array because it is a function of the position: A(x,y,z), so each position in space has a value depending on its coordinates.
I used the following loop to make A into a scalar for each coordinate (x,y,z) and plot A as the colour of each point:
Nx=10;
x1=0.3;
x=linspace(-x1,x1,Nx);y=linspace(-x1,x1,Nx);z=linspace(-x1,x1,Nx);
for a=1:Nx
for b=1:Nx
for c=1:Nx
d=x(a);e=y(b);f=z(c);
g=A(a,b,c);
scatter3(d,e,f,50,g);
end
end
end
Where A is a 3D array which is a function of x,y,z: A(x,y,z).
I also had a look at the links you added, and was able to make some slices to further visualise the data, and as a result I have a very nice 3D scatter and slice plot which shows the data very clearly!
Thanks a lot.
wendy wang
wendy wang el 4 de Feb. de 2015
Editada: wendy wang el 4 de Feb. de 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!!
Wendy

Iniciar sesión para comentar.

Más respuestas (1)

uri iger
uri iger el 7 de Ag. de 2018
Hi! so if I have about 14M points, what do I use?
Thanks a lot! Uri

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by