Color plots on surface of sphere

I would like to use Sage to draw colormap plots of spherical functions on the surface of spheres. I want to produce something like this example.

Are such plots currently possible in Sage, or using optional toolkits? I would like to have a color plots of arbitrary functions f(theta,phi).

Moreover, is it possible to have contour plots of such functions as well?

edit retag close merge delete

If it is possible using scipy and matplotlib, then you can use those directly in sage. I don't think it is possible by using some Sage function directly.

( 2013-01-30 21:04:28 -0500 )edit

Sort by » oldest newest most voted

Something like this:

var('x,y')
cm = colormaps.spring
cf = lambda x,y: (sin(x) + cos(y)) % 1
spherical_plot3d(1,(x,0,4*pi/2),(y,0,pi),color=(cf,cm)).show(aspect_ratio=(1,1,1))


The look is not as smooth as one would like with the default number of plot points.

For a smoother look, increase the number of plot points.

sage: cm = colormaps.spring
sage: f = lambda x, y: 1
sage: cf = lambda x, y: (sin(x) + cos(y)) % 1
sage: p = spherical_plot3d(f, (0, 2*RDF.pi()), (0, RDF.pi()), color=(cf, cm), plot_points=200)
sage: p.show(aspect_ratio=1, viewer='threejs')


Higher values of plot_points increase resolution (but also time to display the plot).

Try for example plot_points=400 or even plot_points=800...

more

I don't think the Sage 3d graphics allow very much flexibility for coloring currently. Here is an example showing how to color a 3d surface using matplotlib, though: http://stackoverflow.com/a/6543777/1200039

more