1

I am totally new to LaTeX and pgfplots,... I copied an example for pie charts from another blog. The problem: I don't want the labels in my pie chart. Could you please help me?

This is what I have already (H_S_3 is the name of my plot):

\DTLloaddb{H_S_3}{H_S_3.txt}

\begin{document}
\begin{figure}[htbp]
\centering

%colours
\DTLsetpiesegmentcolor{1}{black!50}
\DTLsetpiesegmentcolor{2}{pink}
\DTLsetpiesegmentcolor{3}{green!25}
\DTLsetpiesegmentcolor{4}{blue!70}
\DTLsetpiesegmentcolor{5}{black!15}
\DTLsetpiesegmentcolor{6}{pink!92}

%sans-serif:
%\renewcommand*{\DTLdisplayinnerlabel}[1]{\textsf{#1}}
%\renewcommand*{\DTLdisplayinnerlabel}[1]{\textit{#1}}

\DTLpiechart{
    variable=\quantity,
    %innerlabel={\DTLpiepercent\%},
    %outerlabel={\name\ (\DTLpievariable)},
    }
    {H_S_3}{%
\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}

How can I delete the numbers from my pie chart?

my preamble:

\usepackage{geometry}

\geometry{a4paper,left=28mm,right=28mm, top=25mm, bottom=25mm} 
\usepackage{acronym}

\usepackage{booktabs}
\usepackage[pdftex]{graphicx}
%\usepackage{ucs}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[ngerman]{babel}
\usepackage{amsmath,amssymb,amstext}
\usepackage{graphicx}

\usepackage{datapie}

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

%PGF Plots
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Please complete your code with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Jun 23 '14 at 16:53
  • Please don't break the code into different parts in your question; instead, edit your question to turn your code into a minimal working example (MWE). – jub0bs Jun 23 '14 at 17:04
  • Note that you're not actually using pgfplots here, which doesn't have features for making pie charts. datapie is a part of the datatool bundle, and is not related to pgfplots. – Torbjørn T. Jun 23 '14 at 17:10
2

You can set the formatting of the number with the innerlabel key. Note in your example that there is a commented line that says

%innerlabel={\DTLpiepercent\%},

Change this to

innerlabel={},

and the numbers will be removed.

A complete example:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.csv}
Name,Quantity
"Apples",30
"Pears",25
"Lemons,Limes",40.5
"Peaches",34.5
"Cherries",20
\end{filecontents*}


\usepackage{datapie}
\DTLloaddb{\jobname}{\jobname.csv}
\begin{document}
\DTLpiechart{
    variable=\quantity,
    innerlabel={},  % <-- 
    }
    {\jobname}{%
\name=Name,\quantity=Quantity}
\end{document}

enter image description 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.