2

I am trying to make a simple pie chart with pgf-pie, but for a reason unknown to me the labels I use don't display correctly.

Here is the chunk of code I've copied from the manual into my .tex file :

\begin{tikzpicture}
    \pie[color ={ cyan!10 , cyan!40, cyan!70,  cyan!100}, explode=0.1] {10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}

Here is a screenshot of what I get :

Numbers appear close to the labels

And here is a picture of what I'd like to obtain : Screenshot taken from the manual

Does anybody knows why I get these numbers and how to get rid of them ?

edit : Here is a minimal working example

\documentclass{article}
\usepackage[frenchb]{babel}
\usepackage{pgf-pie}

\begin{document}
\begin{tikzpicture}
    \pie[color ={ cyan!10 , cyan!40, cyan!70,  cyan!100}, explode=0.1]{10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}
\end{document} 
  • 2
    Your code is wrong. I get the error message: ! File ended while scanning use of \\pie. Please edit the question and add a minimal but working example (MWE) instead of a code snippet. – Schweinebacke Jul 07 '17 at 15:36
  • Right sorry I'll add a more complete version. Thanks to that I noticed that the problem only appears when I use [frenchb]{babel} so, thanks for the help ! – Alexandre Leonardi Jul 07 '17 at 15:51
  • I cannot reproduce the problem with your example. Nevertheless, the package name is pgf-pie. So you will get a warning, if you load it using \usepackage{pgf-pie-0.2.1/pgf-pie}. And if you load pgfplots (which is not needed for pgf-pie) you should set option compat (see the pgfplots manual for more information). – Schweinebacke Jul 07 '17 at 15:57
  • you find error in code snippet yourself. Correcting it (in your edit) in question means, that you not need an answer anymore ... Howrver, line \usepackage{pgf-pie-0.2.1/pgf-pie} is rather strange. – Zarko Jul 07 '17 at 16:02
  • @Schweinebacke I modified my code according to your comment. However, I actually can reproduce the problem with the snippet I put in my post so... No clue about why it doesn't do it for you. I found a solution anyway (answer below)

    @Zarko yep I changed that line to \usepackage{pgf-pie} ; the question was still opened because I still got the same unwanted behavior when compiling the code in my post with pdflatex.

    – Alexandre Leonardi Jul 10 '17 at 08:45
  • Compare the file versions. See the list at the end of my answer. Maybe you need an update. – Schweinebacke Jul 10 '17 at 10:14

2 Answers2

3

There was a missing ] in the original question at the end of the option list of \pie in your code snippet. Nevertheless, with

\documentclass{article}

\usepackage[frenchb]{babel}
\usepackage{pgf-pie}

\begin{document}
\begin{tikzpicture}
    \pie[color ={ cyan!10 , cyan!40, cyan!70,  cyan!100}, explode=0.1] {10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}

\end{document}

I get

enter image description here

If you want different colors, you should change option color, e.g.,

\listfiles
\documentclass{article}

\usepackage[frenchb]{babel}
\usepackage{pgf-pie}

\begin{document}
\begin{tikzpicture}
    \pie[color ={ cyan!10 , cyan!40, yellow, orange}, explode=0.1] {10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}

\end{document}

enter image description here

I'm using (excerpt from log file with \listfiles):

   babel.sty    2017/06/29 3.12 The Babel package
 frenchb.ldf    2017/04/30 v3.3a French support from the babel system
 pgf-pie.sty    2011/10/02 v0.2 Some LaTeX macros for pie chart by using PGF/Tikz package.
     pgf.sty    2015/08/07 v3.0.1a (rcs-revision 1.15)

Nevertheless, depending on the labels and the babel languages, it could be necessary to use

\usetikzlibrary{babel}

after loading pgf-pie. But this is speculative only, because I did not find an example for the need with pfg-pie.

Schweinebacke
  • 26,336
  • 2
    Thanks but this typo was only in the post, not in my actual code (it appears I'm not very gifted at copying and pasting... somehow). While trying to do a functioning example, I discovered that the problem appears only when I use \usepackage[frenchb]{babel} so this is probably just an incompatibility issue – Alexandre Leonardi Jul 07 '17 at 15:55
0

Same issue here. Weird numbers before label when using pgf-pie.

enter image description here

I also use the

\usepackage[french]{babel}

on my document.

I tried the solution from @Schweinebacke. I just added \usetikzlibrary{babel} after \usepackage{pgf-pie}, like this :

\usepackage{pgf-pie}
\usetikzlibrary{babel}

And that’s it ! No more issue with labels.

enter image description here