2

I would like to add extra text under the legend or next to pie chart where it looks good. But I don't know how. Can someone help me? Would like to add: n = 77 77 is the total of all pie-pieces. Thank you!


\usepackage{pgf-pie}

\begin{figure}[h!]
\centering
\begin{tikzpicture}
\pie[sum=auto, radius=2, color={cyan!90, green!70, blue!40, magenta!90}, text=legend]{22/Staatstheater, 9/Landestheater, 38/Stadttheater, 8/Fusionierte Theater}
]
\end{tikzpicture}
\caption[Verteilung der Theatertypen]{Verteilung der Theatertypen}
\label{fig:verteilung_theatertypen}
\end{figure}```

2 Answers 2

2

Here, I use \stackinset to inset the extra text with the bottom right of the inset located 21 pt from the right side and 5pt from the bottom edge of the pgf-pie image.

I inset a 3-line \Longstack, which is, itself, left-aligned.

The stackinsets can be nested, as demonstrated in the MWE.

\documentclass{article}
\usepackage{pgf-pie,stackengine}
\setstackEOL{\\}
\begin{document}
\begin{figure}[h!]
\centering
\stackinset{c}{-67pt}{c}{-22pt}{wildebeasts}{%
\stackinset{r}{21pt}{b}{5pt}{%
  \Longstack[l]{$n=77$\\77 is the total\\of all pie pieces}}{%
\begin{tikzpicture}
\pie[sum=auto, radius=2, color={cyan!90, green!70, blue!40, magenta!90}, text=legend]{22/Staatstheater, 9/Landestheater, 38/Stadttheater, 8/Fusionierte Theater}
]
\end{tikzpicture}}}
\caption[Verteilung der Theatertypen]{Verteilung der Theatertypen}
\label{fig:verteilung_theatertypen}
\end{figure}
\end{document}

enter image description here

8
  • thank you! but why isn't it working when I delete \stackinset{c}{-67pt}{c}{-22pt}{wildebeasts}{%
    – qu33ristan
    Feb 25, 2021 at 14:15
  • @qu33ristan You need to also remove the closing brace...there are three after the ending tikzpicture...make it two. Feb 25, 2021 at 14:26
  • oh yes! thank you!
    – qu33ristan
    Feb 25, 2021 at 14:27
  • having an idea how to change the font size to \footnotesize?
    – qu33ristan
    Feb 25, 2021 at 14:49
  • @qu33ristan You can add \footnotesize immediately prior to \Longstack or prior to wildebeasts in my example. Feb 25, 2021 at 15:40
1

The wheelchart package, which I wrote, can be used.

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.

enter image description here

\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\wheelchart[
  counterclockwise,
  data=,
  legend row={\tikz\fill[\WCvarB,draw=black] (0,0) rectangle (0.3,0.3); & \WCvarC},
  legend={
    \node[anchor=west] at (2.5,0) {%
      \begin{tabular}{l@{ }l}%
      \WClegend%
       & $n=\WCtotalnum$\\%
       & $\WCtotalnum$ is the total\\%
       & of all pie pieces\\%
      \end{tabular}%
    };
  },
  radius={0}{2},
  slices style={\WCvarB,draw=black},
  start angle=0,
  wheel data={\WCvarA}
]{%
  22/cyan!90/Staatstheater,
  9/green!70/Landestheater,
  38/blue!40/Stadttheater,
  8/magenta!90/Fusionierte Theater%
}
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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