# how do i plot a parabola in the x=2 plane?

I apologize, for I am very new to sage. Here is what I input; the error was that y was not defined.

f(x)=x^2
P=implicit_plot3d(lambda x,y,z:x-2,(-2,2),(-2,2),(-2,8))
plot(f)+plot3d(P)

edit retag close merge delete

You can use var('y') to define y as a variable, and similarly for z.

( 2020-02-05 01:28:50 +0100 )edit

Sort by ยป oldest newest most voted

To get your plot using the parametric_plot3d command that vdelecroix suggested, you could try:

u = var('u')
parametric_plot3d([2,u,u^2],(u,-2,2))


The result, running in a SageCellServer is shown:

more

Note that the command var('u') defines u: you should be able to use var('u') rather than u = var('u'). Unfortunately many of the examples in the Sage documentation needlessly use the longer version.

( 2020-02-05 07:47:36 +0100 )edit

Good point. It's a habit I struggle to break.

( 2020-02-05 20:11:18 +0100 )edit

First of all, P is in itself a graphics object. Writing plot3d(P) does not make much sense.

Secondly, f is a one-variable function so that plot(f) is a 2 dimensional picture (that works). But then the addition plot(f)+plot3d(P) is trying to concatenate a 2-dimensional and a 3-dimensional picture that looks weird.

Now, to draw a curve in 3d you can for example use parametric_plot3d.

more