First time here? Check out the FAQ!

Ask Your Question
4

Color plots on surface of sphere

asked 12 years ago

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?

Preview: (hide)

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 ( 12 years ago )

2 Answers

Sort by » oldest newest most voted
1

answered 6 years ago

FrédéricC gravatar image

updated 6 years ago

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

Preview: (hide)
link
1

answered 12 years ago

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

Preview: (hide)
link

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: 12 years ago

Seen: 1,504 times

Last updated: Apr 08 '19