I am trying to obtain a pie chart and bar chart on the right which shows the details (magnification) of one of the slices of the pie chart (please see attached image). I already used the code provided by Bordaigorl here to obtain the pie chart (see MWE below). Now I am struggling to get the bar chart on the right. How do I obtain this? Thanks enter image description here Here's my MWE:

    legend label/.style={font={\scriptsize},anchor=west,align=left},
    legend box/.style={rectangle, draw, minimum size=5pt},
    axis label/.style={anchor=east,font={\tiny}},
\tikzstyle{bar chart}=[
    bar width/.code={
    bar/.style={very thick, draw=white},
    bar label/.style={font={\bf\small},anchor=north},
    bar value/.style={font={\footnotesize}},
    bar width=.75,

\tikzstyle{pie chart}=[
    slice/.style={line cap=round, line join=round, very thick,draw=white},
    pie title/.style={font={}},
    slice type/.style 2 args={
        values of ##1/.style={}

    \node[pie title] at (90:1.3) {#2};
    \foreach \v/\s in{#3}{
        \pgfmathsetmacro{\nextA}{\curA + \deltaA}

        \path[slice,\s] \c
            -- +(\curA:\r)
            arc (\curA:\nextA:\r)
            -- cycle;
        \pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)}

        \path \c -- node[pos=\d,pie values,values of \s]{$\v\%$} +(\midA:\r);


        \foreach \n/\s in {#2}
                  ++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
    pie chart,
    slice type={hardcoal}{blue!20},
    slice type={lignite}{red!20},
    slice type={nuclear}{gray!40},
     slice type={res}{green!20},
    slice type={ps}{red!50!yellow},
     slice type={ng}{yellow!60},
    pie values/.style={font={\small}},
\pie[xshift=1.2cm,values of ps/.style={rotate=45,font=\scriptsize},
values of ng/.style={rotate=60},values of nuclear/.style={pos=0.75},
values of hardcoal/.style={pos=0.75},align=center]{}{18.8/hardcoal,24.9/lignite,15.5/nuclear,25.7/res,5.4/ps,9.6/ng}
\legend[shift={(0cm,-1cm)}]{{Hard coal}/hardcoal, {Lignite}/lignite, {Nuclear}/nuclear}
\legend[shift={(1.25cm,-1cm)}]{{Renewables}/res, {Pumped storage, Heating oil, others}/ps,{Natural gas}/ng}


Which gives me this: enter image description here

1 Answer 1


The wheelchart package, which I wrote, can be used.

A command \WCtest is defined of which the output depends on whether the percentage is larger than 25. This command is used in the keys data and wheel data. Here, the percentage is obtained with \WCperc.

The gap between the slices is obtained with the key gap=0.02.

The color of the slices is determined by the key slices style=slice\WCcount. Here the colors are defined as slice1 and so on and \WCcount gives the current number of the slice.

The bar is also drawn with a \wheelchart by using the key ybar={2}{5} which gives a width of 2 and a height of 5. This bar is positioned with the key at={(5,-2.5)}, which defines the point below left of the bar.

enter image description here

  anchor xsep=15,
  data=\WCtest{}{\WCvarB{} \WCperc},
  perc precision=1,
  slices style=slice\WCcount,
  start half=0,
  wheel data=\WCtest{\WCvarB\\\WCperc}{},
  wheel data style={white,align=center}
  5.4/{Heating oil,\\Pumped storage\\and others},
  9.6/Natural gas,
  18.9/Hard coal,
\foreach\n in {1,-1}{
  \draw ({\n*25.7*1.8}:3)--(5,{\n*2.5});
  data=\WCvarB{} \qty{\WCvarA}{\percent},
  data sep=0,
  data style={anchor=west},
  slices style=bar\WCcount,
  1.0/Municipal waste,
  0.2/Wind offshore,
  8.9/Wind onshore%

You must log in to answer this question.

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