我使用了另一个主页上的模板来构建图形。它几乎就是我想要的样子,但我找不到如何在图形中插入误差线的描述。我已经尝试在坐标后面加上 +-(2,2),但没有用。我可能需要在其中添加更多信息,但我真的不知道该怎么做。如果有人能帮助我,我将不胜感激!
这是一个最小的例子:
\documentclass{article}
\usepackage{caption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\pgfplotsset{every tick label/.append style={font=\tiny}}
\begin{figure}
\begin{tikzpicture} [scale=0.63,transform shape]
\begin{axis}[ymin=0, ymax=100,
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={Investitionswahrscheinlichkeit},
symbolic x coords={HCLP,HCMP,LCLP,HCHP,LCMP,LCHP},
xtick=data,
xticklabel style = {font=\tiny}, %Schriftgröße x-Achse
]
\addplot coordinates {(HCLP,20.8571) (HCMP,44.5714) (LCLP,49.7143) (HCHP,76.2857) (LCMP,87.4286) (LCHP,96.2857)
};
\addplot coordinates {(HCLP,22.3602) (HCMP,50.9317) (LCLP,43.4783) (HCHP,75.4658) (LCMP,81.677) (LCHP,90.0621)
};
\end{axis}
\end{tikzpicture}
\hskip 1pt % insert a non-breaking space of specified width.
%
\begin{tikzpicture}[scale=0.63,transform shape]
\begin{axis}[ymin=0, ymax=100,
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={Investitionswahrscheinlichkeit},
symbolic x coords={HCLP,HCMP,LCLP,HCHP,LCMP,LCHP},
xtick=data,
xticklabel style = {font=\tiny}, %Schriftgröße x-Achse
]
\addplot coordinates {(HCLP,57.1643) (HCMP,81.6143) (LCLP,77.6075) (HCHP,87.7644) (LCMP,97.3111) (LCHP,96.8377)
};
\addplot coordinates {(HCLP,51.699) (HCMP,82.8229) (LCLP,74.4283) (HCHP,94.009) (LCMP,96.8706) (LCHP,98.7352)
};
\end{axis}
\end{tikzpicture}
\hskip 1pt % insert a non-breaking space of specified width.
%
\begin{tikzpicture}[scale=0.63,transform shape] %Vergrößerungsfaktor
\begin{axis}[ymin=0, ymax=100,
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={Investitionswahrscheinlichkeit},
symbolic x coords={HCLP,HCMP,LCLP,HCHP,LCMP,LCHP},
xtick=data,
xticklabel style = {font=\tiny}, %Schriftgröße x-Achse
]
\addplot coordinates {(HCLP,54.4571) (HCMP,83.0186) (LCLP,74.8108) (HCHP,94.2) (LCMP,91.7701) (LCHP,95.1)
};
\addplot coordinates {(HCLP,59.2885) (HCMP,90.9365) (LCLP,76.3163) (HCHP,95.9797) (LCMP,89.4322) (LCHP,99.2942)
};
\end{axis}
\end{tikzpicture}
\caption{Investitionswahrscheinlichkeiten}
\label{Abbildung3}
\end{figure}
\end{document}
答案1
我找到了问题的答案。我必须像这样更改 \addplot 命令:
代替
\addplot coordinates {(HCLP,20.8571) (HCMP,44.5714) (LCLP,49.7143) (HCHP,76.2857) (LCMP,87.4286) (LCHP,96.2857)
};
我写
\addplot[error bars/.cd,
y dir=both,y explicit,
] coordinates {(HCLP,20.8571) +-(4.84312,4.84312) (HCMP,44.5714) +-(6.17599,6.17599) (LCLP,49.7143) +- (6.38184,6.38184) (HCHP,76.2857) +- (4.15925,4.15925) (LCMP,87.4286) +- (2.61732,2.61732) (LCHP,96.2857) +- (1.17514,1.17514)
};
并且它运行完美:)