[Tex/LaTex] Create Yes/No bar charts

bar chart

I am collating data from a survey and I want to create a bar graph like the one below:
A yes/No bar chart

Can anyone provide me with a template of that chart? I tried to inflect bar chart and stick the two together but it does not work very well.
Thanks!

Best Answer

This looks similar, except:

  • missing thumb up/thumb down symbols;
  • negative values;
  • some lesser issues.

enter image description here

\documentclass[tikz,border={40pt}]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}[axis x line=top,
    axis y line=none,
    bar width=16pt,
    xmax=25,
    xmin=-25,
    ymax=3.5,
    ymin=-1,
    width=9cm,
    height=5cm,
    nodes near coords,
    point meta=explicit symbolic,
    every node near coord/.append style={font=\tiny},
    legend columns=2,
    legend style={
        at={(0.5,0)},
        anchor=north}
]
    \addplot[xbar,fill=blue!20,nodes near coords align={left}] plot coordinates{(10,0) [18 to 24] (15,1) [25 to 34] (7,2) [35 to 45] (17,3) [>45]};
        \addlegendentry{Yes};
    \addplot[xbar,fill=red!20,nodes near coords align={right}] plot coordinates{(-11,0) [18 to 24] (-13,1) [25 to 34] (-15,2) [35 to 45] (-8,3) [>45]};
        \addlegendentry{No};

    \draw (axis cs:0,-0.5) -- (axis cs:0,4);
\end{axis}
\end{tikzpicture}
\end{document}
Related Question