ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 05 Feb 2020 20:11:18 +0100how do i plot a parabola in the x=2 plane?https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-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)Tue, 04 Feb 2020 23:19:29 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/Comment by John Palmieri for <p>I apologize, for I am very new to sage. Here is what I input; the error was that y was not defined.</p>
<pre><code>f(x)=x^2
P=implicit_plot3d(lambda x,y,z:x-2,(-2,2),(-2,2),(-2,8))
plot(f)+plot3d(P)
</code></pre>
https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49796#post-id-49796You can use `var('y')` to define `y` as a variable, and similarly for `z`.Wed, 05 Feb 2020 01:28:50 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49796#post-id-49796Answer by vdelecroix for <p>I apologize, for I am very new to sage. Here is what I input; the error was that y was not defined.</p>
<pre><code>f(x)=x^2
P=implicit_plot3d(lambda x,y,z:x-2,(-2,2),(-2,2),(-2,8))
plot(f)+plot3d(P)
</code></pre>
https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?answer=49791#post-id-49791First 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](https://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/parametric_plot3d.html).Tue, 04 Feb 2020 23:46:05 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?answer=49791#post-id-49791Answer by dazedANDconfused for <p>I apologize, for I am very new to sage. Here is what I input; the error was that y was not defined.</p>
<pre><code>f(x)=x^2
P=implicit_plot3d(lambda x,y,z:x-2,(-2,2),(-2,2),(-2,8))
plot(f)+plot3d(P)
</code></pre>
https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?answer=49797#post-id-49797To 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](https://sagecell.sagemath.org/) is shown:
![image description](/upfiles/1580866832779753.jpg)Wed, 05 Feb 2020 02:41:51 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?answer=49797#post-id-49797Comment by John Palmieri for <p>To get your plot using the <code>parametric_plot3d</code> command that vdelecroix suggested, you could try:</p>
<pre><code>u = var('u')
parametric_plot3d([2,u,u^2],(u,-2,2))
</code></pre>
<p>The result, running in a <a href="https://sagecell.sagemath.org/">SageCellServer</a> is shown:
<img alt="image description" src="/upfiles/1580866832779753.jpg"></p>
https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49800#post-id-49800Note 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.Wed, 05 Feb 2020 07:47:36 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49800#post-id-49800Comment by dazedANDconfused for <p>To get your plot using the <code>parametric_plot3d</code> command that vdelecroix suggested, you could try:</p>
<pre><code>u = var('u')
parametric_plot3d([2,u,u^2],(u,-2,2))
</code></pre>
<p>The result, running in a <a href="https://sagecell.sagemath.org/">SageCellServer</a> is shown:
<img alt="image description" src="/upfiles/1580866832779753.jpg"></p>
https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49811#post-id-49811Good point. It's a habit I struggle to break.Wed, 05 Feb 2020 20:11:18 +0100https://ask.sagemath.org/question/49788/how-do-i-plot-a-parabola-in-the-x2-plane/?comment=49811#post-id-49811