Skip to content

Circle

Circle

Bases: DrawingObject

A class to create circles in the tikz environment.

Parameters:

Name Type Description Default
center Union[Tuple[float, float], Point]

Pair of floats representing the center of the circle

required
radius float

Length (in cm) of the radius

required
options str

String containing the drawing options (e.g, "Blue")

''
action str

The type of TikZ action to use. Default is "draw".

'draw'

center property writable

center: Point

Returns a Point object representing the center of the circle.

from tikzpy import TikzPicture
tikz = TikzPicture()
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.center, text="O")
tikz.show()

east property

east: Point

Returns a Point object representing the east point on the circle.

from tikzpy import TikzPicture
tikz = TikzPicture()
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.east, text="$E$", options="right")
tikz.show()

north property

north: Point

Returns a Point object representing the north point on the circle.

from tikzpy import TikzPicture
tikz = TikzPicture()
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.north, text="$N$", options="above")
tikz.show()

south property

south: Point

Returns a Point object representing the south point on the circle.

from tikzpy import TikzPicture
tikz = TikzPicture()
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.south, text="$S$", options="below")
tikz.show()

west property

west: Point

Returns a Point object representing the west point on the circle.

from tikzpy import TikzPicture
tikz = TikzPicture()
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.west, text="$W$", options="left")
tikz.show()

point_at_arg

point_at_arg(theta: float, radians: bool = False) -> tuple

Returns the point on the circle at angle theta. Both degrees and radians can be specified.

from tikzpy import TikzPicture
tikz = TikzPicture(center=True)
circle = tikz.circle((0,0), 1, options="fill=ProcessBlue!30", action="filldraw")
tikz.node(circle.point_at_arg(45), text="$\pi/2$", options="right")
tikz.node(circle.point_at_arg(135), text="$3\pi/4$", options="left")
tikz.node(circle.point_at_arg(270), text="$3\pi/2$", options="below")
tikz.show()

Examples

Here we create several circles, making use of the action parameter.

from tikzpy import TikzPicture

tikz = TikzPicture()
tikz.circle((0, 0), 1.25) #action="draw" by default
tikz.line((0, 0), (0, 1.25), options="dashed")
tikz.circle((3, 0), 1, options="thick, fill=red!60", action="filldraw")
tikz.circle((6, 0), 1.25, options="Green!50", action="fill")
tikz.show()

We can also use circles to create the Hawaiian Earing.

from tikzpy import TikzPicture

tikz = TikzPicture()

radius = 5
for i in range(1, 60):
    n = radius / i
    tikz.circle((n, 0), n)
tikz.show()