How can I make a 4D contour plot?
Show older comments
Hello there!
I have a set of data, totally unrelated to each other.
I have 'x', 'y' and 'z' variables that create a sphere for me. I want to introduce a new variable 'c' for each point. 'c' corresponds to a contour. So that I will get a new sphere where each point is blue for little amounts of 'c' and red for big amounts.
This is what I do now:
0. Creating Variables x, y and z.
1. Use Delaunay triangulation:
tri = delaunay(x,y);
2. Plot it with trisurf:
h = trisurf(tri, x, y, z).
Now how do I add c as a contour for each point?
2 Comments
Philippe Corner
on 14 Jan 2019
Dear charlie, did you solved your request? Im right now looking for something similar maybe you could help me. Thanks
John D'Errico
on 14 Jan 2019
@Phillippe. Will you please stop reviving multiple different questions. The various question you have revived are not the same. So your question is at best somewhat related. If you have a SPECIFIC question, then ask it.
Answers (1)
Walter Roberson
on 2 Jul 2012
0 votes
I do not have access to MATLAB today, so I cannot explore to see exactly how the trisurf() is constructed. The documentation indicates that a patch object is returned. It should be possible to set the FaceVertexCData patch property to set the vertex colors. This might possibly require redefining how the patch is specified, possibly even to the point where it would be easier to patch() directly instead of using trisurf(). [I would need to experiment to determine the ease of the change.)
trisurf() allows a C (color) argument which specifies one color per face. The patch returned can be modified to one color per vertex instead, but in order to proceed you need to decide two things: how do you want the edge colors to be determined, and how do you want the face colors to be determined? When you switch to vertex coloring, you lose a lot of control over edge colors, with the most direct control being either to not draw edges at all, or to draw the edge colored according to the lower-numbered vertex of the two edge endpoints, making the coloring dependent on the order you created the vertex list in.
If you are really only interested in the color at the vertices and not in the edge or face colors, you should consider using scatter3(x,y,z,PointSize,c) instead of the steps you list above.
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!