# Display a scalar as color over a surface

Hello All,
I have a scalar function (a potential) defined on a 3-dimensional
cartesian space V(x,y,z) and an arbitrary surface (a boundary) set by
the function f(x,y,z)=a. I would like to paint the value of V(x,y,z)
on the surface defined by f in the (x,y,z) domain.
Specifically I was thinking of rewriting f in the form of Z=f(X,Y)
and plot it with surface plot
plot_surface(X, Y, Z, cmap=cm.coolwarm)
This give me my boundary surface but its color is set by Z while I
would like if to be set by my other function V evaluated on the
surface.

Please let me know if any of you have a good suggestion. Thank you,
– Philippe.

I just sent a similar question in last week. This is basically the functionality I'm looking for too. In MATLAB this can be done with the trisurf plotting function. Matplotlib has a plot_trisurf method for an axis provided by loading the mplot3d module, but as far as I can tell, you can either give a surface a constant color or you can choose a cmap and have it color the surface according to the Z values of surface points.

If anyone knows of a way to make Philippe's plot with Matplotlib, I'd love to know.

Byron Boulton

···

From: Philippe Piot [mailto:philippe.piot@…287…]
Sent: Saturday, January 17, 2015 1:25 PM
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] Display a scalar as color over a surface

Hello All,
I have a scalar function (a potential) defined on a 3-dimensional
cartesian space V(x,y,z) and an arbitrary surface (a boundary) set by
the function f(x,y,z)=a. I would like to paint the value of V(x,y,z)
on the surface defined by f in the (x,y,z) domain.
Specifically I was thinking of rewriting f in the form of Z=f(X,Y)
and plot it with surface plot
plot_surface(X, Y, Z, cmap=cm.coolwarm)
This give me my boundary surface but its color is set by Z while I
would like if to be set by my other function V evaluated on the
surface.
Please let me know if any of you have a good suggestion. Thank you,
-- Philippe.