So... I think I understand how each triangular surface gets colored, for example:

% Pretend X, Y, and Z defined above

Tri = delaunay(X,Y);

C = Z;

trisurf(Tri,X,Y,Z,C)

However, it doesn't make sense (to me) why to requireC to be the same size asX,Y, orZ. It would make more sense (to me) to write thetrisurf function such that theC vector be the same length asTri so that each face (i.e., defined by the indices in each row ofTri) can be colored according to some property of that specific face (e.g., the dip angle or dip direction of the face)?

Is there a work-around I am not aware of to get the desired effect? Or do I need to make my own copy of the TriSurf function and modify from there?

% returns a column vector (same length as Tri) with angle of dip for each triangle

% patch defined by each row of Tri (i.e., vertex indices of single triangle patch)

C_Tri = TriDip(X,Y,Z,Tri);

hh = trisurf(Tri,X,Y,Z);

% Additional bit to control color of each patch individually

set(gca,'CLim',[min(C_Tri), max(C_Tri)]);

set(hh,'FaceColor','flat',...

'FaceVertexCData',C_Tri,...

'CDataMapping','scaled');

I borrowed the above bits from the Matlab help page forpatch (which I wasn't aware of when I posted this question). A lot more helpful coloring options for patch type objects are available on that page, too.

{RANT} Even though this work-around example is available to get the desired effect, I still do not get why the default usage of this function should expect that theC vector should be the same length/size asX,Y, orZ. Why would someone (the majority of the time) want to color the patch surface according to a value associated with one of its three vertices? [Still not clear what one of three vertices is used to identify how patch gets colored.] Seems (to me) to be a much harder way of controlling the property each face gets colored with. {/RANT}

RE RANT: It all depends on what you are trying to do. One of the most common applications of triangulation is to connect sparse/irregular samples of a continuous function (well water depth, for example) into a surface, which is more convenient with the default behavior. In that case, you can think of the color at the vertices as the sampled value of the function. trisurf with 'Edgecolor', 'none', 'facecolor', 'interp' gives about as credible a version of the raw data as is available. When the points aren't too close together, it can be useful to overlay a plot of dots at the sample points. You could, of course, interpolate the data to a fixed grid (interp2) or form a gridded surface with gridfit to beat down sampling errors, but neither will preserve the full fidelity of the raw samples in a way that scales as you zoom in, which trisurf will. All that said, any default can be a problem when you are trying to do something else. Ergo, options... which might be a bit lacking for your desires.

Curious: What is it you are doing that the Cvalue is a characteristic of the surface, rather than of the verticies (as above)? Depending on the answer, you might be able to use the vornoi diagram dual, which has a vertex to the circumcneter of each face, and triangulates those. In essence, you could interpolate from face to face, rather than from vertex to vertex. This does lose information about the face edges, so it may or may not be suitable for your needs.

Hi Darin, I am doing what I gave as an example in my answer above - trying to plot the dip angle & dip direction onto the face of each Delaunay triangle. My answer above solves my problem, so no need to go into different methods (for now).

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.