3

I have the following pie chart and I would like to decrease the width of the black border line.

\documentclass{article}
\usepackage{pgf-pie} 
\begin{document}

\begin{figure}[htbp]
\resizebox{0.4\textwidth}{!}{
\centering
\begin{tikzpicture}[font=\tiny] 
\pie[radius=1.2,rotate=0,color={blue, red, yellow, green}]  
 {40/foo0, 51/foo1, 6/foo2, 3/foo3} 
\end{tikzpicture}
}
\centering
\caption{foo foo foo}
\label{fig:foo}
\end{figure}

\end{document}

I tried the following solution

  \documentclass{article}
  \usepackage{pgf-pie} 
  \begin{document}

  \begin{figure}[htbp]
  \centering
  \resizebox{0.4\textwidth}{!}{
    \begin{tikzpicture}[font=\tiny]
      \pie[
        radius=1.2,
        rotate=0,
        color={blue, red, yellow, green},
        style={border=1pt}
      ]{
        40/foo0,
        51/foo1,
        6/foo2,
        3/foo3
      }
    \end{tikzpicture}
  }
  \caption{foo foo foo}
  \label{fig:foo}
  \end{figure}

  \end{document}

It does the needed job, but I get the following error

Package pgfkeys Error: I do not know the key '/tikz/border=1pt' and I am going to ignore it. Perhaps you misspelled it.

How do I resolve this error?

2
  • 1
    So, is that with the pgf-pie package ? An MWE starting from \documentclass[...]{...} to \end{document} would be much appreciated !
    – Partha D.
    Aug 26, 2023 at 2:27
  • @ParthaD. Yes it is. The question is updated with the requested lines. Sep 17, 2023 at 14:10

3 Answers 3

4

In the tikzlibrarypie.code file, we have, line 238 style={thick}. (default parameters)

By replacing in your code style={border=1pt} by style =thin or style =very thin, we may get what you want.

3

The answer below uses the wheelchart package, which I wrote.

The line width can be changed with the key line width in the settings of the key slices style.

enter image description here

\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\begin{document}
\begin{tikzpicture}
\wheelchart[
  counterclockwise,
  pie,
  slices style={
    fill=\WCvarB,
    draw=black,
    line width=0.5pt
  },
  start angle=0,
  wheel data=\WCperc
]{%
  40/blue/foo0,
  51/red/foo1,
  6/yellow/foo2,
  3/green/foo3%
}
\end{tikzpicture}
\end{document}
1

One (not-so-scientific) way could be to scale the tikzpicture up to say 4 times including the text, and then use \scalebox{0.25} to scale it down again to the original size.

\documentclass[border=0.2cm]{standalone}
\usepackage{pgf-pie}

\newcommand{\piechart}{%
      \pie[
        radius=1.2,
        rotate=0,
        color={blue, red, yellow, green},
        % style={border=1pt}
      ]{
        40/foo0,
        51/foo1,
        6/foo2,
        3/foo3
      }
}
 
\begin{document}
 
\begin{tikzpicture}
    \piechart
\end{tikzpicture}

\scalebox{0.25}{%
  \begin{tikzpicture}[scale=4, 
   every node/.style={scale=4}]
    \piechart
  \end{tikzpicture}
}
 
\end{document}

which, apparently works --

pie-chart with thick and thin lines

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .