Plotting a color function on a sphere

6 ビュー (過去 30 日間)
Pablo
Pablo 2011 年 6 月 19 日
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

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 6 月 19 日
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 件のコメント
Pablo
Pablo 2011 年 6 月 19 日
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...

サインインしてコメントする。


Patrick Kalita
Patrick Kalita 2011 年 6 月 21 日
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.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by