You see the following code, which draw you a pie chart



    \pie[rotate=20, color={white}, sum=auto, after number=, radius=2] {10/, 10/, 10/, 10/, 10/,10/, 10/, 10/}



I want the numbers 1 to 8 instead of 10. Is this with the command \pie possible?

  • Do you want the segments to be each 1/8 of total size and just number it from 1 to 8? – moospit Dec 18 '15 at 12:05
  • @moospit yes that's right. When I write the numbers 1 to 8 in the command line. LateX change the size of this pie, The 8 sectors of the circle should be the same size, only the description should be different (from 1 to 8 instead of 10) – danielg Dec 18 '15 at 12:32

I am not aware if pgf-pie is supporting this. Otherwise you can use the following code to create your chart. It could also be used in a newcommand or the pic-environment to make it reusable.

You can adjust the parameters mysegments (number of segements) and myradius (radius of segments) for customization.

\documentclass[tikz, border=5mm]{standalone}

    \foreach \x in {1,...,\mysegments} {
        \draw (0,0) --++ (360/\mysegments*\x:\myradius) arc (360/\mysegments*\x:360/\mysegments*(\x+1):\myradius);
        \node at (360/\mysegments*\x-180/\mysegments:\myradius/2) {\x};

rendered image

Or with 15 segments (\def\mysemgments{15}): rendered image


If you want the segments to be able to have different sizes, you can do it like this:


\documentclass[tikz, border=2mm]{standalone}


%[fill color] parts/color, size, rotate
{   \xdef\PieSum{0}
    \foreach \Seg/\Col in {#2}
    {   \pgfmathparse{\PieSum+\Seg}
        \foreach \Seg/\Col [count=\C] in {#2}
        {   \pgfmathsetmacro{\PieDeg}{\Seg/\PieSum*360}
            \fill[#1, \Col, draw=black] (0,0) -- ++ (\PieDone:#3) arc (\PieDone:\PieDone+\PieDeg:#3) -- cycle;
            \node at  (\PieDone+\PieDeg/2:#3*0.7) {\C};




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.