I have been using the extremely nice 3D pie chart code posted by Alain Matthes as an answer to this question for quite some time. I've constantly been tweaking it to get some features function more nicely - for examples, the individual sectors can now be named (instead of just using their index). My latest addition was an attempt to rotate the whole thing, such that the angle would not necessarily start at the mathematical 0 position, but can be shifted arbitrarily. However, I can't seem to get it to work:
\documentclass{standalone}
\usepackage{pgfplots,tikz}
\usetikzlibrary{fadings}
\pgfkeys{%
/piechartthreed/.cd,
scale/.code = {\def\piechartthreedscale{#1}},
mix color/.code = {\def\piechartthreedmixcolor{#1}},
mix rate high/.code = {\def\piechartthreedmixratehigh{#1}},
mix rate low/.code = {\def\piechartthreedmixratelow{#1}},
background color/.code = {\def\piechartthreedbackcolor{#1}},
name/.code = {\def\piechartthreedname{#1}}}
\newcommand\piechartthreed[2][]{%
\pgfkeys{/piechartthreed/.cd,
scale = 1,
mix color = gray,
mix rate high = 20,
mix rate low = 5,
background color = white,
zeroangle/.store in = \zeroan,
zeroangle = 0,
name = pc}
\pgfqkeys{/piechartthreed}{#1}
\begin{scope}[scale=\piechartthreedscale]
\begin{scope}[xscale=5,yscale=3]
\path[preaction={fill=black,opacity=.8,path fading=circle with fuzzy edge 20 percent,transform canvas={yshift=-15mm*\piechartthreedscale}}] (0,0) circle (1cm);
\fill[gray](0,0) circle (0.5cm);
\path[preaction={fill=\piechartthreedbackcolor,opacity=.8,path fading=circle with fuzzy edge 20 percent,transform canvas={yshift=-10mm*\piechartthreedscale}}] (0,0) circle (0.5cm);
\pgfmathsetmacro\totan{0}\global\let\totan\totan
\pgfmathsetmacro\bottoman{180}\global\let\bottoman\bottoman
\pgfmathsetmacro\topan{0}\global\let\topan\topan
\begin{scope}[draw=black,thin]
\def\piechartthreed@norm{0}
\foreach \name/\an/\col [count=\xi] in {#2}{%
\pgfmathparse{\piechartthreed@norm+\an}\xdef\piechartthreed@norm{\pgfmathresult}
}
\foreach \name/\val/\col [count=\xi] in {#2}{%
\pgfmathparse{360/\piechartthreed@norm * \val}\let\an\pgfmathresult
\pgfmathsetmacro\finan{\totan+\an+\zeroan}
\pgfmathsetmacro\midan{\totan+\an/2+\zeroan}
\pgfmathsetmacro\began{\totan+\zeroan}
\def\space{ }
\coordinate (\piechartthreedname\space\name) at (\midan:0.75cm);
\ifdim 180pt>\began pt
% inner border
\shadedraw[left color=\col!\piechartthreedmixratehigh!\piechartthreedmixcolor,right color=\col!\piechartthreedmixratelow!\piechartthreedmixcolor,draw=black,very thin]
(\began:.5cm)-- ++(0,-3mm) arc(\began:\finan:.5cm) -- ++(0,3mm) arc(\finan:\began:.5cm);
\fi
\ifdim 360pt<\finan pt
% inner border
\shadedraw[left color=\col!\piechartthreedmixratehigh!\piechartthreedmixcolor,right color=\col!\piechartthreedmixratelow!\piechartthreedmixcolor,draw=black,very thin]
(\began:.5cm)-- ++(0,-3mm) arc(\began:\finan:.5cm) -- ++(0,3mm) arc(\finan:\began:.5cm);
\fi
\fill[\col!\piechartthreedmixratehigh!\piechartthreedmixcolor,draw=black] (\began:0.5cm)--(\began:1cm) arc(\began:\finan:1cm) --(\finan:0.5cm) arc(\finan:\began :0.5cm);
\ifdim 180pt<\finan pt
% outer border
\pgfmathsetmacro\bbegan{max(\began,180)}
\pgfmathsetmacro\bfinan{min(\finan,360)}
\shadedraw[left color=\col!\piechartthreedmixratehigh!\piechartthreedmixcolor,right color=\col!\piechartthreedmixratelow!\piechartthreedmixcolor,draw=black,very thin]
(\bbegan:1cm)-- ++(0,-3mm) arc(\bbegan:\bfinan:1cm) -- ++(0,3mm) arc(\bfinan:\bbegan:1cm);
\fi
\pgfmathsetmacro\totan{\totan+\an}\global\let\totan\totan
}
\end{scope}
\draw[thin,black](0,0) circle (0.5cm);
\end{scope}
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\piechartthreed[scale=0.7,
mix color=gray,
mix rate high=80,
mix rate low=60,
zeroangle = 180,
]{%
yy/0.228/yellow,
zz/2.67/pink,
cc/2.9/orange,
tt/6.3/green,
gg/8.56/red,
ww/21.6/blue,
bb/57.5/brown%
}
\draw[black] (pc bb) -- (-4, 2 ) --++ (-3,0) node[anchor=south west] {$H \to b\bar{b} $} node[anchor=north west] {$ 57.5 \pm 1.9 $};
\draw[black] (pc ww) -- (-4,-2 ) --++ (-3,0) node[anchor=south west] {$H \to W^+W^- $} node[anchor=north west] {$ 21.6 \pm 0.9 $};
\draw[black] (pc yy) -- (-4, 0 ) --++ (-3,0) node[anchor=south west] {$H \to \gamma\gamma$} node[anchor=north west] {$0.228 \pm 0.011$};
\draw[black] (pc gg) -- ( 4,-2 ) --++ ( 3,0) node[anchor=south east] {$H \to gg $} node[anchor=north east] {$ 8.56 \pm 0.86 $};
\draw[black] (pc tt) -- ( 4,-0.75 ) --++ ( 3,0) node[anchor=south east] {$H \to \tau^+\tau^-$} node[anchor=north east] {$ 6.30 \pm 0.36 $};
\draw[black] (pc cc) -- ( 4, 0.75 ) --++ ( 3,0) node[anchor=south east] {$H \to c\bar{c} $} node[anchor=north east] {$ 2.90 \pm 0.35 $};
\draw[black] (pc zz) -- ( 4, 2 ) --++ ( 3,0) node[anchor=south east] {$H \to ZZ $} node[anchor=north east] {$ 2.67 \pm 0.11 $};
\end{tikzpicture}
\end{document}
Playing with the zeroangle
parameter a bit, you can see that it works nicely for values in the range 0-90, but after that, weird graphic effects pop up, and I don't really understand why this happens.
Any suggestion on how to fix this?
>:-|