I would like to have the numbers that are inside the pie chart to be in the legend. How can I make that happen?
Here is the MWE:
\documentclass{article}
\usepackage{pgf-pie}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}
\pie[text=legend,style=drop shadow,radius=2]{51.3/Protestant, 23.9/Roman Catholic, 3.3/Other Christian, 1.7/Jewish, 0.7/Buddhist, 0.6/Muslim, 0.4/Hindu, 1.2/Other religions, 16.1/No religion }
\end{tikzpicture}
\end{document}
EDIT:
I also have another pie chart, where the text is quite long. How can I set the width of the text so that it wraps around before the page ends? Here is what it looks like:
I forgot that PGF-PIE was not on CTAN. Here is a link to the google source: http://code.google.com/p/pgf-pie/
Best Answer
The
pgf-pie
package is not as flexible as one wishes. Unfortunately,etoolbox
refuses to patch, so we do it manually.Open up (make a copy/backup) the
pgf-pie.sty
file and scroll to the end, there is a part enclosed in\iflegend … \fi
. Replace the enclosedscope
environment with:Now you can use the
number in legend
style (which should come afterbefore number
andafter number
!).For long legend entries, you can use the
every legend entry
style, sayThe setup now allows this (the node distance is set to zero as the
inner ysep
creates, in my opinion, enough room between the entries.You need the
positioning
library for the newerbelow=of
syntax.Code
Output