3

I refer to the question discussed: Fractions inside the pieces

Now, I could not find out two more things:

(1): How to label selected pie slices? The option /tikz/nodes={text opacity=0, overlay} hides all numbers and text parameters of the \pie command. To point out what I want I add my code at the pies, but I made it crabwise.

(2): How to fill the slices with pattern? Is there a an easy way to include this option to the \pie options?

\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}

enter image description here

1
  • Could you clarify what you mean by "label selected pie slices"? You can label around the pies by adding a name after the number i.e. {2/A,2/B,2/C,2/D}. Aug 8, 2019 at 13:16

1 Answer 1

1

I think you want something like that:

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .