Ask Your Question
1

level/contour curves in 3D

asked 2012-08-01 19:52:54 +0200

heptadecagon gravatar image

updated 2017-01-08 12:09:21 +0200

FrédéricC gravatar image

Is there a way to graph level curves of a function $f(x,y)$ in 3D at their respective heights? (Much like contourplot3d in Maple.) Thanks.

To make things clearer: what I'd like to see is a 3D plot with level curves (not surfaces). We start with a function of 2 variables (not three) and I'd like to see the 'exploded' contour plot so that the level curves are graphed at their respective z-altitudes. Makes sense?

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
4

answered 2012-08-02 21:49:30 +0200

calc314 gravatar image

updated 2012-08-02 22:52:08 +0200

Below is a bit of a hack, but I think it does what you want.

var('x,y,z')
f(x,y)=x^2+3*y^2
levels=[1,2,3,4]
epsilon=0.1
p=plot3d(f(x,y),(x,-2,2),(y,-2,2),color='khaki',opacity=0.7)
for h in levels:
    p+=implicit_plot3d(f(x,y)==h,(x,-2,2),(y,-2,2),(z,h,h+epsilon))

show(p)

image description

edit flag offensive delete link more

Comments

1

Small variation: var('x,y,z') sum([implicit_plot3d(x^2-y^2==level,(x,-4,4),(y,-4,4),(z,level,level+0.1)) for level in srange(-10,10,2)])

achrzesz gravatar imageachrzesz ( 2012-08-03 02:19:14 +0200 )edit

Cool use of srange!

calc314 gravatar imagecalc314 ( 2012-08-03 11:00:52 +0200 )edit

Thanks for the solution, though, like you said, it's a little bit of a hack.

heptadecagon gravatar imageheptadecagon ( 2012-08-07 18:29:49 +0200 )edit
1

answered 2012-08-01 21:46:19 +0200

calc314 gravatar image

updated 2012-08-02 08:37:06 +0200

You can use contour_plot and can specify the heights you want as follows.

var('x,y')
contour_plot(x^3+x*y,(x,-4,4),(y,-4,4),contours=[0,1,2,3])

For a 3D version, see 3D contours.

edit flag offensive delete link more

Comments

I think he means can one do a 3d plot in the same way?

kcrisman gravatar imagekcrisman ( 2012-08-01 22:35:22 +0200 )edit

Good point! I'll edit my answer.

calc314 gravatar imagecalc314 ( 2012-08-02 08:35:58 +0200 )edit

Indeed, what I'd like to see is a 3D plot with level curves (**not surfaces**). We start with a function of 2 variables (**not three**) and I'd like to see the 'exploded' contour plot so that the level curves are graphed at their respective $z$-altitudes. Makes sense?

heptadecagon gravatar imageheptadecagon ( 2012-08-02 18:08:52 +0200 )edit

Look at the next answer

achrzesz gravatar imageachrzesz ( 2012-08-02 18:20:35 +0200 )edit
1

answered 2012-08-02 16:12:02 +0200

achrzesz gravatar image

updated 2012-08-02 16:45:56 +0200

One can use gnuplot (in Sage)

   sage: gnuplot_console()
    #and then
    set contour surface
    set cntrparam levels incremental -10,2,10
    unset surface 
    set isosamples 100,100
    splot [-4:4] [-4:4] [-11:11] x**2-y**2
edit flag offensive delete link more

Comments

Thanks, that looks interesting but I would rather avoid having to use gnuplot.

heptadecagon gravatar imageheptadecagon ( 2012-08-02 18:40:58 +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

1 follower

Stats

Asked: 2012-08-01 19:52:54 +0200

Seen: 2,905 times

Last updated: Aug 02 '12