[pstricks] [texhax] Pie chart

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sat Oct 24 21:36:55 CEST 2009

Ulrich Lindberg Olsen schrieb:

> > I have tried to follow one of the exmples in the documentation on
> > pstricks. It's the one starting on page 277 on doing a pie chart. For
> > some reason I can't get it to work.
> >
> > I have attached my .tex file.
> >
> > Can you please tell me why it isn't working?

put the definition of the macro between
and use the optional argument of pstricks for the color names
(see example)

and you should have a look at pstricks-add, it has better support
for pie charts.



% #1 = Values, #2 = Labels, #3 = Styles, #4 = Starting angle
% To compute in \pst at dimd the sum of all the values
\pst at dimd=\z@
\Multido{\iNbValues=\z at +\@ne}{9999}{%
	\csname check#1\endcsname(\multidocount)%
\advance\pst at dimd by \cachedata\p@
\degrees[\pst at number{\pst at dimd}]
% To compute the starting angle
\pst at dimh=\pst at dimd
\divide\pst at dimh by 360
\multiply\pst at dimh by #4
% Loop on slices
	% Slice
	\pst at dimg=\pst at dimh
	\csname check#1\endcsname(\multidocount)%
	\advance\pst at dimh by \cachedata\p@
	\csname check#3\endcsname(\multidocount)%
		{\pst at number{\pst at dimg}}{\pst at number{\pst at dimh}}
	% Label
	\advance\pst at dimg\pst at dimh
	\divide\pst at dimg\tw@
	\uput{2.2}[\pst at number{\pst at dimg}](0,0){%
		\large\csname #2\endcsname(\multidocount)}}

\readarray{Values}{32.7 & 19.3 & 12.4 & 27.6 & 6.9}
% Don't leave blanks between labels and between styles!

\newpsstyle{}{}% For undefined styles




More information about the PSTricks mailing list