Plotting a color function on a sphere

12 visualizaciones (últimos 30 días)
Pablo
Pablo el 19 de Jun. de 2011
Dear kind helpers,
I have a question which I have not been able to resolve yet.
I have three vectors x, y and z with x(i), y(i) and z(i) giving a point on the unit sphere. I also have a fourth vector c of the same length as x,y and z containing function values, where c(i) corresponds to the function value at the point (x(i), y(i), z(i)) on the sphere.
I want to make a contour plot of the function c(i) on the sphere defined by all the points (x(i), y(i), z(i)). How can I do such a thing?
Best wishes,
Pablo

Respuestas (2)

Walter Roberson
Walter Roberson el 19 de Jun. de 2011
The following will not be a contour plot as such, but it might serve your purpose:
pointsize = 8;
scatter3(x,y,z,pointsize,c)
If you want something closer to a contour plot, you could use histc() or interp1() to effectively quantize the c values and pass the quantized values in to scatter3 instead of c itself.
  1 comentario
Pablo
Pablo el 19 de Jun. de 2011
I already found out this option indeed... But I have to give neat figures in a report, so unfortunately this does not serve my purpose...

Iniciar sesión para comentar.


Patrick Kalita
Patrick Kalita el 21 de Jun. de 2011
There are a couple of avenues to explore. I wouldn't say either of them are particularly easy, unfortunately.
Idea 1: Use contourslice. The idea here would be that you'd first have to interpolate your scattered data c onto a uniform 3D grid (e.g. using meshgrid and TriScatteredInterp). Then you'd pass the gridded x, y, z, and c to contourslice along with 2D arrays Xi, Yi, Zi that define the surface of a sphere where the contours will lie.
Idea 2: Turn your x, y, and z data into spherical coordinates (using cart2sph). Then you can compute the contours in the 2D theta-phi space using contourc. The output of contourc will also be in terms of theta and phi. You can transform back into Cartesian coordinates with sph2cart (the radius being 1 at every point). Finally you can manually draw the contours with the resulting x, y, and z coordinates.

Categorías

Más información sobre Surface and Mesh 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