I am trying to write the code for the following bar chart. enter image description here So far, I can only do this: enter image description here As you can see, I failed to produce the legends similar to the original chart. The legend in the original chart is right next to each chart. I would very appreciate if anyone can help. Thank you in advance.

    bar width=0.2cm,
    %enlarge x limits=0.25,
    tick align=inside,
    major grid style={draw=black},
    %enlarge y limits={value=.1,upper},
    xmin=0, xmax=100,
    %axis x line*=bottom,
    %axis y line*=right,
    %hide y axis,axis line style={shorten >=-15pt, shorten <=-15pt},
    symbolic y coords={1990-1997, 1998-1999, 2000-2008},
                legend style={
            legend columns=-1,
            /tikz/every even column/.append style={column sep=0.5cm}
    %nodes near coords={\pgfmathprintnumber[precision=0]{\pgfplotspointmeta} }
    \addplot [draw=none, fill=blue!30] coordinates {
        (94.4597,2000-2008) };
    \addplot [draw=none,fill=red!30] coordinates {
        (94.4597,2000-2008) };
       \node [left] at (0,5) {D}; 
    \legend{blue, red}
  • 1
    Try xbar=0pt. – Bobyandbob Feb 23 '18 at 9:38
  • It should remove the space between the bars. – Bobyandbob Feb 23 '18 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.