how to plot a circle (without circle())
Hello, I know you can plot a circle with circle(x,y,radius), but how do you do it with plot()?
There are several ways you can use plot or similar functions.
use plot with the circle as the graphics object you already discovered:
sage: plot(circle((0, 0), 2))
express y as a function of x for two half-circles (this will miss part of the circle):
sage: p = plot(sqrt(4 - x^2), (-3, 3))
sage: q = plot(-sqrt(4 - x^2), (-3, 3))
sage: (p + q).show(aspect_ratio=1)
use an implicit plot starting from an equation for the circle:
sage: x, y = SR.var("x y")
sage: implicit_plot(x^2 + y^2 - 4, (x, -3, 3), (y, -3, 3))
use a parametric plot for the circle; here is one (there are many others):
sage: t = var('t')
sage: parametric_plot((2*cos(t), 2*sin(t)), (t, 0, 2*pi))
In this case I would recommend the parametric plot rather than the functions or the implicit plot.
Asked: 2017-09-20 22:43:54 +0100
Seen: 2,226 times
Last updated: Sep 21 '17
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.