# Unit circle with sine and cosine in TikZ, explained

> How the unit circle with sine and cosine is drawn in TikZ: polar and perpendicular coordinates, an arc, a rotated radius, and two variations.

URL: https://www.labcanvas.com/tikz/examples/mathematics/unit-circle-sine-and-cosine

Updated 2026-11-22. Original figure: Unit circle: sine and cosine, © Petar Veličković, MIT licence (licence text: https://www.labcanvas.com/tikz-library/credits.html#petarv), from https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Coordinate%20systems/coordinate_systems.tex. Walkthrough and variations by LabCanvas; the variation code is CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/). Pictures typeset with TeX Live 2026 and PGF 3.1.12. Category: [TikZ mathematics examples](https://www.labcanvas.com/tikz/examples/mathematics).

## Quick answer

This figure shows the unit-circle definition of sine and cosine: a point P on a circle at angle α, the radius r to it, and its horizontal and vertical components x (red) and y (blue). It is a dozen lines of TikZ built on two kinds of coordinate: polar coordinates such as `(60:2.5cm)`, which place P from its angle and radius, and the perpendicular coordinate `(60:2.5cm |- 0,0)`, the foot of P on the x axis. The angle is an `arc`, and the radius is a horizontal line turned by `rotate=60`.

## The figure and its code

![A circle centred on x and y axes, a green radius r from the centre to the point P at 60 degrees, a red segment x along the x axis from the centre to below P, a blue vertical segment y from there up to P, and a small arc marked alpha at the centre.](https://www.labcanvas.com/tikz-snippets/fig-unit-circle-sine-and-cosine/original.webp)

Copyright (c) 2016 Petar Veličković, MIT licence (https://www.labcanvas.com/tikz-library/credits.html#petarv). The code below is exactly the library's file (pdfLaTeX); its first lines name the source and the licence, and the MIT licence asks that they stay with the code. Open it in the TikZ editor from the page: https://www.labcanvas.com/tikz/examples/mathematics/unit-circle-sine-and-cosine

```latex
% Unit circle: sine and cosine
% Source: https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Coordinate%20systems/coordinate_systems.tex
% Copyright (c) 2016 Petar Veličković. MIT licence: https://github.com/PetarV-/TikZ/blob/master/LICENSE
% The licence’s copyright and permission notice: https://www.labcanvas.com/tikz-library/credits.html
\documentclass[crop, tikz]{standalone}
\usepackage{tikz}

\usetikzlibrary{calc}

\definecolor{olivegreen}{rgb}{0,0.6,0}

\begin{document}
\begin{tikzpicture}[scale=0.85]
	% Axis
	\draw[thick,-stealth,black] (-3,0)--(3,0) coordinate (A) node[below] {$x$}; % x axis
	\draw[thick,-stealth,black] (0,-3)--(0,3) node[left] {$y$}; % y axis
	\draw[black,thin] (0,0) circle (2.5cm);

	\draw[ultra thick,red] (0,0) -- (60:2.5cm |- 0,0) node[midway,below] {$x$}; % UpOn y axis

	\draw (1,0) arc (0:60:1) node at ($(60/2:0.7)$) {$\alpha$};
	\draw[ultra thick, blue] (60:2.5cm) -- (60:2.5cm |- 0,0) node[midway,right] {$y$}; % vertical line

	\draw[ultra thick,olivegreen,rotate=60] (0,0) -- node [left] {$r$} (2.5,0) coordinate (B);

	\draw[xshift=-1cm] (B) node[circle,fill,inner sep=1pt,label=above:$P$](e){};
\end{tikzpicture}
\end{document}
```

## Preamble and a named colour

*Lines 5–10 of the code.*

The `standalone` class with the `crop` and `tikz` options crops the page to the picture and loads TikZ (so the explicit `\usepackage{tikz}` is redundant). The `calc` library is needed only for the one `($…$)` coordinate on line 21, which could just as well be written without it. `\definecolor{olivegreen}{rgb}{0,0.6,0}` defines a darker green from red, green and blue fractions, used for the radius.

## Scale, axes and the circle

*Lines 13–17 of the code.*

`scale=0.85` on the picture shrinks every coordinate, including those with units such as `2.5cm`, and therefore the circle as well. It does not shrink the text or the line widths: nodes are not transformed unless asked to, and the coordinate transformation applies to coordinates only. The axes are two arrows with the old `-stealth` tip from −3 to 3. The x axis ends in `coordinate (A)`, a name that nothing uses. `\draw[black,thin] (0,0) circle (2.5cm);` is the circle in the older syntax, with the radius in parentheses.

## Cosine and sine from polar and perpendicular coordinates

*Lines 19–22 of the code.*

`(60:2.5cm)` is a polar coordinate: angle 60°, radius 2.5 cm, the point P. `(60:2.5cm |- 0,0)` is a perpendicular coordinate, the point with the x of P and the y of (0,0): the foot of P on the x axis. The red line from the origin to it is the cosine component, labelled with `node[midway,below]`, and the blue line from P down to it, labelled `node[midway,right]`, is the sine component. (The comment on line 19, “UpOn y axis”, describes the red line wrongly: it lies on the x axis.) Nothing here computes a cosine; TikZ converts the polar point once and reuses its x.

Line 21 draws the angle: `(1,0) arc (0:60:1)` starts at the current point (1, 0) and draws an arc from 0° to 60° with radius 1, in the older `(start:end:radius)` syntax. The α label is a node with its own position, `node at ($(60/2:0.7)$)`: 0.7 cm from the centre at half the angle. The `$…$` calc wrapper is not needed; `(30:0.7)` would give the same point.

## The radius by rotation, and an xshift that does nothing

*Lines 24–26 of the code.*

The radius is drawn as a horizontal line, `(0,0) -- … (2.5,0)`, with `rotate=60` on the path, so it ends at P. `coordinate (B)` at its end stores the transformed position, and the label r is a node written inside the `--`, which puts it at the middle of the line.

Line 26 places the dot and the label P: `\draw[xshift=-1cm] (B) node[…, label=above:$P$](e){};`. The `xshift=-1cm` has no effect, because transformations do not apply to a named coordinate such as `(B)`; the manual says so explicitly for node anchors “even if you have said scale=3 or xshift=4cm”. So P lands exactly at B, on the circle, which is what the picture needs; the option can be deleted. `label=above:$P$` attaches the letter above the small filled circle.

## Techniques used

- [Polar coordinates](https://www.labcanvas.com/tikz/coordinates): `(60:2.5cm)` places a point by angle and distance.
- [Perpendicular coordinates (a |- b)](https://www.labcanvas.com/tikz/coordinates): `(60:2.5cm |- 0,0)` is the foot of P on the x axis.
- [Arcs and circles](https://www.labcanvas.com/tikz/circles-arcs): `arc (0:60:1)` for the angle and `circle (2.5cm)` for the circle.
- [Transformations](https://www.labcanvas.com/tikz/tikzpicture): `scale=0.85` and `rotate=60` act on coordinates, not on text, line widths or named coordinates.

## Variations

Our own code, CC0 1.0, each typeset with TeX Live 2026 in a standalone document with the preamble lines shown.

### Any angle, with the tangent

The same construction driven by one macro, `\def\a{35}`: P is `(\a:1)`, the foot is `(P |- O)`, and the tangent point is computed with `(1, {tan(\a)})`, where the line OP meets the vertical tangent x = 1. The angle is an `angle` pic from the `angles` library, so it follows the macro too. With `scale=2.2` the unit circle has radius 1 in the code and 2.2 cm on paper.

![A unit circle with axes, a green radius labelled 1 to the point P at 35 degrees, a red segment cos alpha along the x axis, a blue vertical segment sin alpha up to P, an orange segment tan alpha on the vertical tangent line at x = 1, a dashed extension of the radius to it, an arc marked alpha, and the caption alpha = 35°: P = (cos alpha, sin alpha), T = (1, tan alpha).](https://www.labcanvas.com/tikz-snippets/fig-unit-circle-sine-and-cosine/any-angle.webp)

*sine, cosine and tangent at α = 35°, all positions computed from one macro*

Preamble: `\usepackage{tikz}`, `\usetikzlibrary{angles, quotes}`

```latex
\begin{tikzpicture}[scale=2.2, >=stealth]
  \def\a{35}  % the angle in degrees: change it and everything follows
  \draw[->] (-1.25,0) -- (1.5,0) node[below] {$x$};
  \draw[->] (0,-1.25) -- (0,1.4) node[left] {$y$};
  \draw (0,0) circle[radius=1];
  \coordinate (O) at (0,0);
  \coordinate (X) at (1,0);
  \coordinate (P) at (\a:1);
  \coordinate (C) at (P |- O);          % the foot of P on the x axis
  \coordinate (T) at (1, {tan(\a)});    % where OP meets the tangent x = 1
  \draw[gray] (1,-1.2) -- (1,1.25);
  \draw[gray, dashed] (P) -- (T);
  \draw[orange!85!black, very thick] (X) -- (T) node[midway, right] {$\tan\alpha$};
  \draw[red, very thick] (O) -- (C) node[midway, below] {$\cos\alpha$};
  \draw[blue, very thick] (C) -- (P) node[pos=0.4, left] {$\sin\alpha$};
  \draw[green!50!black, very thick] (O) -- (P) node[midway, above left] {$1$};
  \pic[draw, "$\alpha$", angle radius=5mm, angle eccentricity=1.45] {angle = X--O--P};
  \fill (P) circle[radius=0.7pt] node[above] {$P$};
  \node[anchor=north west, font=\small] at (-1.2,-1.3)
    {$\alpha = \a^\circ$: $P = (\cos\alpha, \sin\alpha)$, $T = (1, \tan\alpha)$};
\end{tikzpicture}
```

### The full circle in radians

The unit circle as it is usually taught, with the sixteen standard angles labelled in radians. One `\foreach` over pairs, `\t/\lab in {30/\frac{\pi}{6}, …}`, uses the degrees for the position, `(\t:1)` for the dot and `(\t:1.2)` for the label, and the radians for the text. The red and blue sides show the coordinates of the point at 30°.

![A unit circle with grey spokes to sixteen dots labelled 0, π/6, π/4, π/3, π/2, 2π/3, 3π/4, 5π/6, π, 7π/6, 5π/4, 4π/3, 3π/2, 5π/3, 7π/4 and 11π/6, and a red horizontal side √3/2 and a blue vertical side 1/2 under the point at π/6.](https://www.labcanvas.com/tikz-snippets/fig-unit-circle-sine-and-cosine/radians.webp)

*the unit circle with the sixteen standard angles in radians and the coordinates of the 30° point*

Preamble: `\usepackage{tikz}`

```latex
\begin{tikzpicture}[scale=2.4, font=\footnotesize]
  \draw[->, gray] (-1.45,0) -- (1.5,0) node[right, black] {$x$};
  \draw[->, gray] (0,-1.45) -- (0,1.5) node[above, black] {$y$};
  \draw[thick] (0,0) circle[radius=1];
  % the standard angles: degrees for the position, radians for the label
  \foreach \t/\lab in {0/0, 30/\frac{\pi}{6}, 45/\frac{\pi}{4}, 60/\frac{\pi}{3},
      90/\frac{\pi}{2}, 120/\frac{2\pi}{3}, 135/\frac{3\pi}{4}, 150/\frac{5\pi}{6},
      180/\pi, 210/\frac{7\pi}{6}, 225/\frac{5\pi}{4}, 240/\frac{4\pi}{3},
      270/\frac{3\pi}{2}, 300/\frac{5\pi}{3}, 315/\frac{7\pi}{4}, 330/\frac{11\pi}{6}} {
    \draw[gray!50] (0,0) -- (\t:1);
    \fill (\t:1) circle[radius=0.7pt];
    \node at (\t:1.2) {$\lab$};
  }
  % one reference triangle: the coordinates of the point at 30 degrees
  \draw[red, thick] (0,0) -- ({cos(30)},0) node[midway, below] {$\frac{\sqrt{3}}{2}$};
  \draw[blue, thick] ({cos(30)},0) -- (30:1) node[midway, right] {$\frac{1}{2}$};
\end{tikzpicture}
```

## Frequently asked questions

### How do I draw a unit circle with sine and cosine in TikZ?

Draw the circle with \draw (0,0) circle[radius=1];, put the point at a polar coordinate (\a:1), and draw the cosine from the origin to (P |- 0,0) and the sine from there to P. The any-angle variation on this page does this from one macro.

### Why does xshift have no effect on my node coordinate?

Transformations such as xshift, scale or rotate do not apply to named coordinates and node anchors: (B) is always where B was defined. To shift such a point, give the option inside the coordinate, ([xshift=-1cm]B), or use calc: ($(B)+(-1,0)$).

### What does (60:2.5cm |- 0,0) mean?

It is a perpendicular coordinate: the x of the first point, the polar point at 60° and 2.5 cm, and the y of the second point, (0,0). The result is the foot of that point on the x axis.

## References

- [PetarV-/TikZ at commit 86aee04: Coordinate systems/coordinate_systems.tex (MIT licence)](https://github.com/PetarV-/TikZ/blob/86aee049f5355d77c598b936399e42caf8941e60/Coordinate%20systems/coordinate_systems.tex)
- [PGF/TikZ manual, §13.2.1 Canvas, XYZ, and Polar Coordinate Systems](https://tikz.dev/tikz-coordinates#sec-13.2.1)
- [PGF/TikZ manual, §13.3.1 Intersections of Perpendicular Lines (|- and -|)](https://tikz.dev/tikz-coordinates#sec-13.3.1)
- [PGF/TikZ manual, §14.6 The Circle and Ellipse Operations](https://tikz.dev/tikz-paths#sec-14.6)
- [PGF/TikZ manual, §14.7 The Arc Operation](https://tikz.dev/tikz-paths#sec-14.7)
- [PGF/TikZ manual, §17.7 Transformations (nodes)](https://tikz.dev/tikz-shapes#sec-17.7)
- [PGF/TikZ manual, §17.11 Connecting Nodes: Using Nodes as Coordinates (transformations do not apply)](https://tikz.dev/tikz-shapes#sec-17.11)
- [PGF/TikZ manual, §25.3 Coordinate Transformations (rotate, scale)](https://tikz.dev/tikz-transformations#sec-25.3)
- [PGF/TikZ manual, §41 Angle Library](https://tikz.dev/library-angle)

## TikZ guides for these techniques

- [TikZ coordinates, paths, \foreach, scopes and styles](https://www.labcanvas.com/tikz/coordinates): TikZ coordinates (polar, relative ++, named, calc, intersections), paths and controls, \foreach loops, scopes, \tikzset styles, decorations and grids.
- [How to draw circles, ellipses and arcs in TikZ](https://www.labcanvas.com/tikz/circles-arcs): Draw circles, ellipses and arcs in TikZ: circle[radius], ellipse radii, arc start/end angle and centre, half circles, sectors, pie charts and angle marks.
- [The tikzpicture environment: options, scaling and centring](https://www.labcanvas.com/tikz/tikzpicture): The tikzpicture environment: its options, scale vs transform shape vs \resizebox, centring it in a figure with a caption, and inline TikZ with baseline.
- [TikZ plots with pgfplots: functions, data, scatter, bars and 3D](https://www.labcanvas.com/tikz/plots): Plot in LaTeX with pgfplots: functions, data tables, scatter plots coloured by value, error bars, bar charts, log axes, 3D surfaces and groupplots.
