Ask Your Question
1

Coloring surfaces in plot3d

asked 2012-09-12 18:16:12 +0200

hiho gravatar image

I'm really new with sage, and what I would like is to color a graph from plot3d according to some function (specifically, I would want the hue to vary with the magnitude of the gradient). Is there some way of doing this easily?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2017-01-10 14:06:20 +0200

FrédéricC gravatar image

Something like that is now possible as follows.

var('x,y,z')
cm = colormaps.winter
f = sin(2*z).function(x,y,z)
implicit_plot3d(x^2-y^2*z == 0,(x,-4,4),(y,-4,4),(z,-4,4), color=(f,cm))

where cm is a chosen colormap among those available. Beware that the coloring function f must takes values between 0 and 1.

edit flag offensive delete link more
0

answered 2012-09-13 09:43:52 +0200

niles gravatar image

Yes and no. There is basic functionality for colormaps, as described on the question about coloring by z-level. Sage's colormaps come from matplotlib, and you can define your own colormap functions in matplotlib. Here is the documentation for matplotlib colormaps.

But I don't know if Sage's interface to matplotlib has been extended to all the functionality of matplotlib (probably not). Perhaps you'll need to import matplotlib and use it's plotting functionality directly . . .

It should be possible, but may require learning more about matplotlib and how to use it. Good luck!

edit flag offensive delete link more

Comments

Niles, your ticket http://trac.sagemath.org/sage_trac/ticket/12212 might be relevant here.

kcrisman gravatar imagekcrisman ( 2013-02-24 20:30:30 +0200 )edit

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: 2012-09-12 18:16:12 +0200

Seen: 1,197 times

Last updated: Jan 10 '17