我指的是讨论的问题:碎片内的分数
现在,我又找不到另外两件事:
(1):如何标记选定的饼图切片?该选项 /tikz/nodes={text opacity=0, overlay}
隐藏 \pie
命令的所有数字和文本参数。为了指出我想要的内容,我在饼图上添加了代码,但我将其做得很曲折。
(2):如何用图案填充切片?有没有简单的方法将此选项添加到选项中 \pie
?
\documentclass[fleqn,12pt, a4paper]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{pgfkeys}
\usepackage{pgf}
\usetikzlibrary{shapes, snakes}
\usepackage{tkz-graph}
\usepackage[utf8]{inputenc}
\usepackage{pgf-pie}
\usepackage{xcolor}
\usetikzlibrary{patterns}
\usepgflibrary[patterns]
\begin{document}
\begin{tikzpicture}
\pie[sum=auto, /tikz/nodes={text opacity=0, overlay}]{2/,2/,2/,2/}
\draw [/tikz/nodes={text opacity=10,overlay}] node at (-1,-1) {\Huge $ \frac{1}{4} $};
\pie[pos={8,0},sum=auto, /tikz/nodes={text opacity=0, overlay}]{2/,2/,2/,2/}
\draw [/tikz/nodes={text opacity=10,overlay}] node at (6,-3) {\Huge $ \frac{1}{4} $};
\end{tikzpicture}
\end{document}
答案1
我想你想要这样的东西:
\documentclass[tikz, border=5pt]{standalone}
\usepackage{amsmath}
\usepackage{pgf-pie}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[
mystyle/.style={draw=black, very thick,
postaction={pattern=north west lines, pattern color=black,}
}]
\pie[radius=3,
%sum=auto,
text=inside, % <----
before number=\hphantom, % <----
after number=,
style={mystyle}, % <----
/tikz/nodes={fill=yellow,rounded corners=1pt},
] {25/A, 25/B, 25/$\dfrac14$, 25/D}
\end{tikzpicture}
\end{document}