Ask Your Question

How can i generate a 3D plot with more details?

asked 2012-11-02 05:34:26 -0600

updated 2012-11-02 05:37:05 -0600

How can i generate a 3D plot of the function f(x,y)=x^2+y^2 with the view of all integer values of x,y,z in the graph? For example like this

![x^2+y^2] (

...but with more details.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-11-02 16:35:14 -0600

benjaminfjones gravatar image

updated 2012-11-03 10:48:15 -0600

You can use plot3d to plot your surface and then add to that Graphics object the collection of points you want to visualize:

sage: N = 3
sage: f(x,y)=x^2+y^2
sage: G = plot3d(f, (x,-N,N), (y,-N,N))
sage: points_list = [ (a,b,f(a,b)) for a in [-N..N] for b in [-N..N] ]
sage: G += point(points_list, color='red')
sage: show(G)

Here's a working demo:

edit flag offensive delete link more


it does not work! I tested it. It stops running with a TypeError. TypeError: 'Graphics3dGroup' object is not iterable

elcojon gravatar imageelcojon ( 2012-11-03 05:35:05 -0600 )edit

yeah, that's a typo on my part. It's fixed now

benjaminfjones gravatar imagebenjaminfjones ( 2012-11-03 10:46:32 -0600 )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


Asked: 2012-11-02 05:34:26 -0600

Seen: 169 times

Last updated: Nov 03 '12