How to color a 3d plot by z-level?

i like this post (click again to cancel)
1
i dont like this post (click again to cancel)

I'd like to color a 3d plot based on z-level. I think this is easy to do in Maple or Mathematica, but I've been searching the web for help on doing this in Sage and can't find anything to help with plot3d or implicit_plot3d.

Here's the implicit_plot3d I'm using.

var('x,y,z')    
implicit_plot3d(x^2-y^2*z == 0,(x,-4,4),(y,-4,4),(z,-4,4)).show(mesh=True)

Also, are there color maps in Sage that produce plots with colors and lighting similar to the default in Mathematica?

asked May 09 '12

calc314 gravatar image calc314
1820 3 19 51

updated May 09 '12

Niles also eventually opened up the possibly relevant http://trac.sagemath.org/sage_trac/ticket/12212

kcrisman (Feb 24)

2 Answers:

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

I asked a similar question about using a colormap for implicit_plot3d almost a year ago, and it is still open. @schilly did show how to use matplotlib colormaps for plot3d though, and it's pretty cool:

sage: var('r v')
sage: cmsel = [colormaps['autumn'](i) for i in sxrange(0,1,0.05)]
sage: p = plot3d(0.2*(r**2 + v**2) + cos(2*r)*sin(2*v),(r,-2,2), (v,-2,2), adaptive=True, color=cmsel)
sage: p.show(aspect_ratio=(1,1,1), figsize=[7,3])

image description

And, as @jason-grout said, you can see all of the available colormaps with colormaps.keys().

If you do figure out some way to use colormaps with implicit 3d plots, I would love to hear about it!

link

posted May 10 '12

niles gravatar image niles
3354 5 38 92
http://nilesjohnson.net/

updated May 10 '12

Wow! That does a great job. It would still be great to have it built into the plot3d and implicit_plot3d commands so that it is more friendly and intuitive.

calc314 (May 10 '12)
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

Have a look at this. Is this what you are looking for? You can run matplotlib scripts in sage.

http://matplotlib.sourceforge.net/examples/mplot3d/surface3d_demo.html

link

posted May 09 '12

Shashank gravatar image Shashank flag of United States
1570 5 22 55

That code does produce some good looking plots. However, it is too involved for me to use with calculus students without writing some sort of wrapper for it. Also, I definitely cannot take this as a solution to a colleague who is not an expert programmer. Are there simpler options to get this result?

calc314 (May 10 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: May 09 '12

Seen: 286 times

Last updated: May 10 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.