I know I'm asking a lot. But by chance, is there someone who knows a package capable of drawing nested pie chart in Latex ? Something like this :
PS : It's more curiosity than real need, Python does it very well ;)
I know I'm asking a lot. But by chance, is there someone who knows a package capable of drawing nested pie chart in Latex ? Something like this :
PS : It's more curiosity than real need, Python does it very well ;)
The answer below uses the wheelchart package, which I wrote.
A command \WCtest is defined of which the output depends on whether the percentage is larger than 1. This command is used in the keys data and wheel data.
Using the key gap={\WCpercentage>1?0.03:0}, a gap between slices is created if the percentage is larger than 1. Otherwise, no gap is created.
The legend is determined by the key legend. This is a tabular which is placed in a \node. The rows are determined by the key legend row. The result of all rows can be obtained with \WClegend.
A separate \wheelchart is used for each ring.
\documentclass[border=6pt,dvipsnames]{standalone}
\usepackage{wheelchart}
\usepackage{siunitx}
\sisetup{text-family-to-math}
\begin{document}
\begin{tikzpicture}
\sffamily
\def\WCtest#1#2{\pgfmathparse{\WCpercentage>1?"#1":"#2"}\pgfmathresult}
\pgfkeys{
/wheelchart,
data=\WCtest{}{\qty{\WCvarA}{\percent}},
data style=gray,
gap={\WCpercentage>1?0.03:0},
gap radius=0.03,
start angle=0,
wheel data=\WCtest{\qty{\WCvarA}{\percent}}{},
wheel data pos=0.5
}
\wheelchart[
legend row={\tikz\fill[\WCvarB] (0,0) rectangle (0.3,0.3); & \WCvarC},
legend={
\node[anchor=east] at (-5,0) {%
\begin{tabular}{rl}%
\WClegend%
\end{tabular}%
};
},
middle=District AAL:\\\textcolor{gray}{Rs $12.9$ L},
radius={1.5}{3},
wheel data style=white
]{%
43.1/Cerulean/Residential Buildings,
24/Green/Economic Sectors,
22.1/Red/Critical Buildings,
10.8/gray/Transportation Infrastructure%
}
\wheelchart[
radius={3}{4},
wheel data style=gray
]{%
20.9/Cerulean!50,
16.2/Cerulean!30,
6.02/Cerulean!10,
9.59/Green!50,
9.33/Green!30,
5.11/Green!10,
16.4/Red!50,
5.7/Red!30,
10.6/gray!50,
0.221/gray!30%
}
\end{tikzpicture}
\end{document}