1

I am totally stuck with a problem. Is there any appropriate package for pie charts? I am using datatool right now. But there are a lot of problems: E.g. the labels are overlapping.

Do you have any idea?

That is my datatable:

Serotyp, Anzahl

"Ia",89

"Ib",28

"II",18

"III",294

"IV",3

"V",34

"VI",1

"VII",0

"VIII",0

"IX",1

\documentclass[pdftex,8pt,a4paper]{scrreprt}

\usepackage{geometry}
\geometry{a4paper,left=28mm,right=28mm, top=25mm, bottom=25mm} 
\usepackage{acronym}
\usepackage{booktabs}
\usepackage[pdftex]{graphicx}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath,amssymb,amstext}
\usepackage{graphicx}

\usepackage{datapie}

\usepackage{caption}
\usepackage{array}
\usepackage[automark]{scrpage2}

\usepackage{pgfplots}
\pgfplotsset{compat=1.9}

%my data file
\DTLloaddb{H_S_3}{H_S_3.txt}

\begin{document}

\begin{figure}[htbp]
\centering
&lines
\setlength{\DTLpieoutlinewidth}{0.5pt}

%colour of the segments
\DTLsetpiesegmentcolor{1}{black!50}
\DTLsetpiesegmentcolor{2}{black}
\DTLsetpiesegmentcolor{3}{blue!25}
\DTLsetpiesegmentcolor{4}{green!70}
\DTLsetpiesegmentcolor{5}{black!75}
\DTLsetpiesegmentcolor{6}{black!82}
\DTLsetpiesegmentcolor{7}{black}
\DTLsetpiesegmentcolor{8}{black!20}
\DTLsetpiesegmentcolor{9}{blue}
\DTLsetpiesegmentcolor{10}{green}

%letters
\renewcommand*{\DTLdisplayinnerlabel}[1]{\textsf{#1}}
\renewcommand*{\DTLdisplayinnerlabel}[1]{\textit{#1}}

\DTLpiechart{
    variable=\quantity,
    innerlabel={},
    outerlabel={\name\ (\DTLpievariable)},
    }
    {H_S_3}{%
%name of the column
\name=Serotyp,\quantity=Anzahl}
%Legende
\begin{tabular}[b]{ll}
\DTLforeach{H_S_3}{\name=Serotyp}{\DTLiffirstrow{}{\\}%
\DTLdocurrentpiesegmentcolor\rule{10pt}{10pt} &
\name
}
\end{tabular}
\end{figure}


\end{document}
1

I would recommend the package tikz for this. In this answer, you may have a look on how this could be done.

Till Tantau is giving some interesting hints on pie-charts on page 95 of his TikZ/PGF-Manual (PDF, 8.8 MB). For sure, the source code of his "bad" pie-chart is available somewhere.

One TikZ-solution which focusses on your overlapping-labels-problem can be seen on TeXample.net.

The package pgfplots which is getting kind of standard for data visualization in the last time does not provide pie charts.

The package pstricks is able to draw anything for you as well. In this answer, some example is shown.

One more package (but as you tagged your post with this, you will already know it) is the package pgf-pie. It's documentation can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.