level/contour curves in 3D

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

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?

asked Aug 01 '12

heptadecagon gravatar image heptadecagon
3 4

updated Aug 02 '12

3 Answers:

i like this answer (click again to cancel)
3
i dont like this answer (click again to cancel) heptadecagon has selected this answer as correct

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

link

posted Aug 02 '12

calc314 gravatar image calc314
1855 3 19 53

updated Aug 02 '12

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 (Aug 03 '12)

Cool use of srange!

calc314 (Aug 03 '12)

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

heptadecagon (Aug 07 '12)
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

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.

link

posted Aug 01 '12

calc314 gravatar image calc314
1855 3 19 53

updated Aug 02 '12

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

kcrisman (Aug 01 '12)

Good point! I'll edit my answer.

calc314 (Aug 02 '12)

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 (Aug 02 '12)

Look at the next answer

achrzesz (Aug 02 '12)
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

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
link

posted Aug 02 '12

achrzesz gravatar image achrzesz
1661 4 16 36

updated Aug 02 '12

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

heptadecagon (Aug 02 '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

1 follower

Tags:

Stats:

Asked: Aug 01 '12

Seen: 209 times

Last updated: Aug 02 '12

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