Ask Your Question
4

Color plots on surface of sphere

asked 2013-01-30 12:05:04 +0200

OMF gravatar image

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 flag offensive close merge delete

Comments

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.

ppurka gravatar imageppurka ( 2013-01-31 04:04:28 +0200 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2013-02-01 00:15:15 +0200

Jason Grout gravatar image

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

edit flag offensive delete link more
1

answered 2019-04-07 18:44:01 +0200

FrédéricC gravatar image

updated 2019-04-08 22:40:00 +0200

slelievre gravatar image

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...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-30 12:05:04 +0200

Seen: 1,360 times

Last updated: Apr 08 '19