围绕饼图分解切片的轮状图

围绕饼图分解切片的轮状图

我想知道是否可以围绕初始饼图的分解切片编写轮状图。到目前为止,我的代码生成的饼图的相关切片已分解,周围漂浮着一个笨拙的单独小饼图。理想情况下,人际暴力和集体暴力将围绕“政府和社会”和“紧急情况”类别。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz, pgfplots}
\usepackage{pgf-pie} 

\begin{document}

\hspace{6cm}\begin{minipage}[l]{0.6\linewidth}
\begin{tikzpicture}[scale=0.4]
\tikzstyle{every node}=[font=\small] 

\pie[pos ={1, 2}, 
explode={1, 1, 0, 0, 0, 0, 0},
text=pin, hide number,
    color = {
    blue!40!,
            red!40,
        violet!40!}
]{
9.3/Collective Violence (95.6\%),
2.9/Interpersonal Violence (4.4\%)
}
\end{tikzpicture}
    \end{minipage}%
  \hfill%
     \hspace*{0cm}

     \begin{minipage}[r]{0.09\linewidth}
\begin{tikzpicture}[scale=0.8]
 \noindent
\tikzstyle{every node}=[font=\small]
\pie[pos ={1, 2}, 
explode={0.5, 0.5, 0, 0, 0, 0, 0, 0, 0},
text=pin, hide number,
    color = {
        blue!40!,
        blue!60!,
        red!60, red!70,
        blue!70,
        red!40}
]{
12.2/Government \& Social (12.18\%),
5.4/Emergency (5.40\%),
20.1/Budget \& Debt (20.07\%),
17.3/Infrastructure (17.26\%),
11.0/Business \& Industry (11.04\%),
8.8/Necessities (8.84\%),
6.9/Health (6.89\%),
18.3/Multisector \& Others (13.08\%)
}
\label{fig:}
    \end{tikzpicture}
    \end{minipage}
    \newline
    \raggedright
\footnotesize{\textit{Text}}

\end{document}

我在下面勾勒了我的愿景,希望它可以帮助您直观地了解我的意思。

任何帮助都将不胜感激!谢谢,Leslie

愿景

答案1

饼图是一种糟糕的数据表示方法。爆炸饼图更糟糕。--不可原谅的是带有额外切片的图表,其中面积失去了所有意义。

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgf-pie}
\begin{document}
\begin{tikzpicture}
\pie[
pos={0.05,-0.1},
explode={1, 1},
hide number,
color={blue!40!, red!40},
text opacity=0,
]{
9.3/Collective Violence (95.6\%),
2.9/Interpersonal Violence (4.4\%)
}
\pie[
explode={0.5, 0.5, 0, 0, 0, 0, 0, 0, 0},
text=pin, hide number,
color={blue!40!, blue!60!, red!60, red!70, blue!70, red!40},
font=\small,
]{
12.2/Government \& Social (12.18\%),
5.4/Emergency (5.40\%),
20.1/Budget \& Debt (20.07\%),
17.3/Infrastructure (17.26\%),
11.0/Business \& Industry (11.04\%),
8.8/Necessities (8.84\%),
6.9/Health (6.89\%),
18.3/Multisector \& Others (13.08\%)
}
\node[font=\small, pin=-20:{Collective Violence (95.6\%)}] at (3.8,1) {};
\node[font=\small, pin=20:{Interpersonal Violence (4.4\%)
}] at (3.1,2.4) {};
\end{tikzpicture}
\end{document}

爆炸式饼图,背景中有额外的饼图

答案2

以下答案使用轮图包,是我写的。

百分比是自动计算的,并且可以与一起使用\WCperc

在密钥中slices style我们使用\WClistcolors引用给定密钥的列表中的项目WClistcolors

第一个切片\wheelchart和第二切片使用 键进行移位explode{1,2}=0.5。对于第一个切片,使用 键时没有线lines{1}=0

第二个\wheelchart是用 键定位的atdata和 是由和lines键决定的。data angle shift{list}lines angle shift{list}

在此处输入图片描述

\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\pgfkeys{
  /wheelchart,
  anchor ysep=40,
  counterclockwise,
  data=\WCvarB{} (\WCperc),
  lines,
  perc precision=2,
  slices style={\WClistcolors,draw=black},
  start angle=0
}
\wheelchart[
  data sep{1}=1.5,
  explode{1,2}=0.5,
  lines{1}=0,
  pie,
  WClistcolors={blue!40!,blue!60!,red!60,red!70,blue!70,red!40},
]{%
  12.18/Government \& Social,
  5.40/Emergency,
  20.07/Budget \& Debt,
  17.26/Infrastructure,
  11.04/Business \& Industry,
  8.84/Necessities,
  6.89/Health,
  18.32/Multisector \& Others%
}
\wheelchart[
  at={(12.18*1.8:0.5)},
  data angle shift{list}={-14,-6},
  lines angle shift{list}={-12,0},
  radius={3}{4},
  total angle=12.18*3.6,
  WClistcolors={blue!40!,red!40}
]{%
  95.6/Collective Violence,
  4.4/Interpersonal Violence%
}
\end{tikzpicture}
\end{document}

相关内容