Hey ich möchte ein Balkendiagram bauen. Code ist folgnder: \pgfplotsset{width=10cm,compat=1.15} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, ymax=160, bar width=0.5cm, symbolic x coords={<-9 to -9,-9 to -8,-8 to -7,-7 to -6,-6 to -5,-5 to -4,-4 to -3,-3 to -2,-2 to -1,-1 to 0,0 to 1,1 to 2,2 to 3,3+}, xtick=data, x tick label style={rotate=45, anchor=east}, ylabel={Annual Excess Return (percentage)}, xlabel={}, nodes near coords, nodes near coords align={vertical}, enlarge x limits={abs=1cm}, width=15cm, height=8cm, title={Emerging Market Equity Funds versus MSCI Emerging Market Index}, legend style={at={(0.5,-0.2)},anchor=north,legend columns=-1}, legend cell align={left}, area legend ] \addplot [fill=gray] coordinates {(<-9 to -9,11) (-9 to -8,7) (-8 to -7,18) (-7 to -6,30) (-6 to -5,69) (-5 to -4,97) (-4 to -3,123) (-3 to -2,142) (-2 to -1,136) (-1 to 0,88) (0 to 1,46) (1 to 2,31) (2 to 3,13) (3+,21)}; % Hier der Code für die Linie \draw[dashed] (axis cs: 0,0) -- (axis cs:-1 to 0,160); \end{axis} \end{tikzpicture} \caption{Annual Excess Return of Emerging Market Equity Funds versus MSCI Emerging Market Index} \label{fig:excess_return} \end{figure} Die Linie soll aber genau senkrecht zwischen den Balken 136 und 88 hochgehen. kann mir da jemand helfen? |
Ich vermute, dass du die Linie eher zwischen den beiden Balken bei \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{width=10cm,compat=1.15} \begin{document} \begin{figure} \centering \begin{tikzpicture} \begin{axis}[ ybar, ymin=0, ymax=160, bar width=0.5cm, symbolic x coords={$<$-9 to -9,-9 to -8,-8 to -7,-7 to -6,-6 to -5,-5 to -4,-4 to -3,-3 to -2,-2 to -1,-1 to 0,0 to 1,1 to 2,2 to 3,3+}, xtick=data, x tick label style={rotate=45, anchor=east}, ylabel={Annual Excess Return (percentage)}, xlabel={}, nodes near coords, nodes near coords align={vertical}, enlarge x limits={abs=1cm}, width=15cm, height=8cm, title={Emerging Market Equity Funds versus MSCI Emerging Market Index}, legend style={at={(0.5,-0.2)},anchor=north,legend columns=-1}, legend cell align={left}, area legend ] \addplot [fill=gray] coordinates {($<$-9 to -9,11) (-9 to -8,7) (-8 to -7,18) (-7 to -6,30) (-6 to -5,69) (-5 to -4,97) (-4 to -3,123) (-3 to -2,142) (-2 to -1,136) (-1 to 0,88) (0 to 1,46) (1 to 2,31) (2 to 3,13) (3+,21)}; % Hier der Code für die Linie \draw[dashed] ($(axis cs:-1 to 0,0)!.5!(axis cs:0 to 1,0)$)coordinate(h) -- (h|-current axis.north); \end{axis} \end{tikzpicture} \caption{Annual Excess Return of Emerging Market Equity Funds versus MSCI Emerging Market Index} \label{fig:excess_return} \end{figure} \end{document} beantwortet 12 Jun, 20:14 esdd |