1

I tried to replicate a bar graph for the first time and have two problems with the x-axis. Could someone help me?

This is the graph i would like to replicate. my attempt 1. How do I get a group of bars next to each other separated from another group? And 2. how to center the label for each group?

Here is my MWE and a screenshot.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xlabel = $\beta$,
width=\linewidth,
bar width=30pt,
xtick={},
xticklabels={neutral, anger},
axis lines*=left,
clip=true,
ymin=0,
ymax=1,
ylabel={annual discountfactor},
legend style={at={(1,1)},font=\tiny}
]

\addplot[
fill=blue,
draw=black,
ybar,
point meta=y,
error bars/.cd,
    y dir=both,
    y explicit
] 
table [y error=error] {
x            y           error   
1   0.0401    0.0177 
1.8   0.0252    0.0048
};
\addlegendentry{$\delta_{1}$}
\end{axis}
\end{tikzpicture}
\end{document}

graph which I would like to replicate

Browse other questions tagged or ask your own question.