![为什么我的饼图会移动标签?](https://linux22.com/image/435383/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%E9%A5%BC%E5%9B%BE%E4%BC%9A%E7%A7%BB%E5%8A%A8%E6%A0%87%E7%AD%BE%EF%BC%9F.png)
我有一个tikz图片有几个节点。在每个节点内,我都画了一个带有某些内容的 tikzpicture。有些节点有图表,其他节点有流程图等。
一切似乎都很好。问题是当我将两个包含饼图的节点放在下面时。为什么第二个饼图的切片标签会移位?我该如何修复?
如果我改变图表的顺序,第二个图表总是会取代它的标签。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{pgf-pie}
\usetikzlibrary{shapes.geometric, positioning, backgrounds}
\begin{document}
\begin{figure}[htb]
\centering
\caption{Example of charts 1, 3, 5, and 7 - Total cost per case, activity, resource and time}
\begin{tikzpicture}[align=center,node distance=.3cm and .3cm, framed]
\node (c1) [label=below:Total cost per activity] {\scalebox{.9}{
\begin{tikzpicture}
\pie[sum = auto, radius=2.2, color={gray!10,gray!20,gray!30,gray!40,gray!50,gray!60,gray!70,gray!80}
]{300/a,2997/b,2400/c,900/d,1800/e,2100/f,600/g,600/h}
\end{tikzpicture}
}};
\node (c2) [label=below:Total cost per resource, right=of c1] {\scalebox{.9}{
\begin{tikzpicture}
\pie[radius=1.8, sum = auto, color={gray!10,gray!20,gray!30,gray!40,gray!50}
]{1050/Pete,1399/Sue,2100/Mike,3900/Sara,1250/Ellen}
\end{tikzpicture}
}};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
这轮图我写的包,可以使用。
由第二个变量给出data
,用 表示\WCvarB
。
切片的颜色由键决定slices style
。宏\WCcount
给出切片的当前编号。
由第一个变量给出wheel data
,表示为\WCvarA
。它们的位置由键 决定wheel data pos
。
第二个\wheelchart
是用钥匙定位at
。
\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\pgfkeys{
/wheelchart,
counterclockwise,
data=\WCvarB,
radius={0}{2.5},
slices style={
gray!\fpeval{\WCcount*10},
draw=black
},
start angle=0,
wheel data=\WCvarA,
wheel data pos=0.8
}
\wheelchart[
caption=Total cost per activity
]{300/a,2997/b,2400/c,900/d,1800/e,2100/f,600/g,600/h}
\wheelchart[
at={(6,0)},
caption=Total cost per resource
]{1050/Pete,1399/Sue,2100/Mike,3900/Sara,1250/Ellen}
\end{tikzpicture}
\end{document}