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.Sun, 23 Apr 2017 20:35:36 +0200How to draw x^2-3*y^2=4 2d plot ?https://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/It shows error, when I use 'y' variable, and says it is not defined.
So only plots of the form y=f(x) are allowed. How do I overcome this limitation in plotting?
And also how are 2d plots converted to 3D. I know how to do it. But how is it possible to make a 3d plot of a curve say, sin , as it is inherently in 2 dimensions.Sun, 23 Apr 2017 18:05:08 +0200https://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/Answer by mforets for <p>It shows error, when I use 'y' variable, and says it is not defined.</p>
<p>So only plots of the form y=f(x) are allowed. How do I overcome this limitation in plotting?</p>
<p>And also how are 2d plots converted to 3D. I know how to do it. But how is it possible to make a 3d plot of a curve say, sin , as it is inherently in 2 dimensions.</p>
https://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/?answer=37379#post-id-37379the first issue is probably because you didn't define the variable `y`, this can be done typing `y = var('y')`. The fact that this is not necessary for the `x` variable is because it is predefined at the startup of Sage. If you find yourself using very often the variable `y` (or other variables or functions), then it's possible to load them at startup by using the `init.sage` file, as explained in [sage startup scripts](http://doc.sagemath.org/html/en/reference/repl/startup.html).
for the questions on plotting, you may consider these functions as starting point:
- `implicit_plot`, see [implicit plots doc](https://doc.sagemath.org/html/en/prep/Advanced-2DPlotting.html#contour-type-plots)
- `parametric_plot` for [parametric plots in 2d](https://doc.sagemath.org/html/en/prep/Advanced-2DPlotting.html#parametric-plots) and `parametric_plot3d`, see [parametric plots 3d doc](https://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/parametric_plot3d.html?highlight=parametric_plot3d#module-sage.plot.plot3d.parametric_plot3d)Sun, 23 Apr 2017 20:35:36 +0200https://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/?answer=37379#post-id-37379