Is it possible to have different color for inner and outer face of a 3D plot?

Actually I want to try to plot something like this picture:

http://physics.aps.org/assets/d88621a594e78eea

With a color for inside and another for outside.

Probably not to the level of control one may wish to have, but one can achieve shading effects assuming a light source. plot_surface() can assume a light source for you, or you could provide one IIRC. This isn’t very well documented (in fact, it is downright non-existent!).

The most simple way of getting something like what you want is to set shade=True and not use a colormap. This shades the surface according to the normal vector to the surface.

One can also provide a “lightsource”. I just noticed this is not documented. One can specify a “lightsource” kwarg to plot_surface (note that shade must be set to True, a cmap must be provided, and oddly enough, facecolors has to be not None (this might be a bug)), and a colorbar won’t work (seem to throw an exception…). By default (i.e., lightsource=None), a matplotlib.color.LightSource object with azdeg=135 and altdeg=55 is used to shade based on the data and colormap. You can provide your own light source to achieve the effect you would like by positioning it properly (don’t ask me how, I never played with that part).

I know this was kind of vague, but I hope it is at least somewhat illuminating.

Cheers!
Ben Root

···

On Wed, Sep 19, 2012 at 9:14 AM, Fabien Lafont <lafont.fabien@…287…> wrote:

Actually I want to try to plot something like this picture:

http://physics.aps.org/assets/d88621a594e78eea

With a color for inside and another for outside.