Draw circle with three colours in tikz
I am posting this code, which is from a deleted answer by Zarko on a related question (TikZ: Circle with color transition). It is not my code, so I've made the answer Community Wiki.
\documentclass[border=5mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[radius=32mm]
\foreach \i [count=\ii from 0] in {red, green, blue}
\fill[\i] (0,0) -- (\ii*120:32mm)
arc[start angle=\ii*120,delta angle=120]
-- cycle;
\fill[white] (0,0) circle (16mm);
\end{tikzpicture}
\end{document}
To add the white space between the parts, you can use \fill[\i, draw=white, very thick]
. To make the bars thinner, adjust the size of white circle in the middle.
Edit:
cfr's comment made me read more carefully your question.
Of course, if you need only a line, you may increase the radius of the white internal circle, for example:
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){O}
\foreach \mycolor/\mygrad in {red/0,green/120,blue/240}
\tkzDrawSector[R,draw=white,fill=\mycolor](O,1)(\mygrad,\mygrad+120);
\fill[white] (0,0) circle (.95); % <--- here put the value you like
\end{tikzpicture}
\end{document}
Original answer:
You could also use tkz-euclide
package:
\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,0){O}
\foreach \mycolor/\mygrad in {red/0,green/120,blue/240}
\tkzDrawSector[R,draw=white,fill=\mycolor](O,1)(\mygrad,\mygrad+120);
\fill[white] (0,0) circle (.5);
\end{tikzpicture}
\end{document}
The problem is that an arc
of radius 1 from one coordinate (call it A) which starts at angle X and ends at angle Y will assume that A is at angle of X on the circumference of a circle with radius 1.
So your first arc
assumes that (0,0)
is at zero degrees on the circumference of a circle with radius 1. This means the centre of the circle must be at (-1,0)
.
But your second arc
assumes that (1,0)
is at 120 degrees on the circumference of a circle with radius 1. So the centre must be at (1.5,{.5*(sqrt(3))}
.
Finally, your third arc
assumes that (0,0)
is at 240 degrees on the circumference of a circle with radius 1. So the centre must be at ({cos(60)},{sin(60)})
.
[On the improbable assumption that I've not messed up the geometry at this hour of the night.]
I suggest using polar coordinates instead. Then your arc
s can start at (0:1)
, (120:1)
and (240:1)
which makes things much simpler.
\documentclass[border=10pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [red] (0:1) arc [radius=1, start angle=0, end angle=120];
\draw [green] (120:1) arc [radius=1, start angle=120, end angle=240];
\draw [blue] (240:1) arc [radius=1, start angle=240, end angle=360];
\end{tikzpicture}
\end{document}