Skip to content

Instantly share code, notes, and snippets.

Created Jan 8, 2016
Embed
What would you like to do?
Partycake
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to Overleaf --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you give
% someone the link to this page, they can edit at the same
% time. See the help menu above for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[tikz]{standalone}
\begin{document}
\usepackage[table]{xcolor}
\definecolor{color}{RGB}{0,66,144}
\definecolor{framsokn}{RGB}{125,91,49}
\definecolor{sjalfstaedi}{RGB}{0,0,181}
\definecolor{vinstrigraen}{RGB}{72,142,65}
\definecolor{frjalslyndi}{RGB}{0,142,210}
\definecolor{samfylkingin}{RGB}{198,18,24}
\definecolor{bjoertframtidid}{RGB}{146,39,143}
\definecolor{borgarahreyfingin}{RGB}{242,120,31}
\def\angle{0}
\def\radius{3}
\def\cyclelist{{"orange","blue","red","green"}}
\newcount\cyclecount \cyclecount=-1
\newcount\ind \ind=-1
\begin{tikzpicture}
\begin{tikzpicture}
\foreach \percent/\name/\color in {
14.8/Framsóknarflokkur/framsokn,
23.7/Sjálfstæðisflokkur/sjalfstaedi,
7.2/Borgarahreyfingin/bjoertframtidid,
0.6/Lýðræðishreyfingin,
29.8/Samfylkingin/samfylkingin,
21.7/Vinstrihreyfingin--grænt framboð/vinstrigraen
} {
\ifx\percent\empty\else % If \percent is empty, do nothing
\global\advance\ind by 1 % Advance list index
% Draw angle and set labels
\draw[fill={\color!100},draw={\color}] (0,0) -- (\angle:\radius) arc (\angle:\angle+\percent*3.6:\radius) -- cycle;
\node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\%};
\node[pin=\angle+0.5*\percent*3.6:\name] at (\angle+0.5*\percent*3.6:\radius) {};
\pgfmathparse{\angle+\percent*3.6} % Advance angle
\xdef\angle{\pgfmathresult} % and store in \angle
\fi
};
\end{tikzpicture}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment