von esdd » Mo 29. Mai 2017, 12:52
Vielleicht geht das auch irgendwie eleganter, aber hier ist zumindest mal ein Vorschlag:
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar stacked,
bar width=15pt,
nodes near coords,
enlargelimits=0.15,
legend style={at={(0.5,-0.20)},
anchor=north,legend columns=-1},
symbolic x coords={tool1, tool2},
xtick=data,
x tick label style={rotate=45,anchor=east},
ymajorgrids,
/tikz/mstyle/.style={draw,red,very thick,text=black},
/tikz/mleft/.style={xshift={-(.5*\pgfplotbarwidth+2.5pt)}},
/tikz/mline/.style={insert path={--+({\pgfplotbarwidth+5pt},0pt)}},
]
\path[mstyle]([mleft]axis cs:tool1,2)[mline]node[right]{$2$};
\path[mstyle]([mleft]axis cs:tool2,3)[mline]node[right]{$3$};
\addplot plot coordinates {(tool1,0) (tool2,2)};
\addplot plot coordinates {(tool1,0) (tool2,0)};
\addplot plot coordinates {(tool1,6) (tool2,6)};
\addplot plot coordinates {(tool1,4) (tool2,2)};
\end{axis}
\end{tikzpicture}
\end{document}
Beachte, dass Du beim Zeichnen der Striche die symbolischen x-Koordinaten verwenden musst. Ist es Absicht, dass Du Kompatibilität zu der recht alten Version 1.10 herstellst? Aktuell ist derzeit 1.14
- Dateianhänge
-

- gl_stackedplotmark.png (9.91 KiB) 1254 mal betrachtet
Vielleicht geht das auch irgendwie eleganter, aber hier ist zumindest mal ein Vorschlag:
[code]\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar stacked,
bar width=15pt,
nodes near coords,
enlargelimits=0.15,
legend style={at={(0.5,-0.20)},
anchor=north,legend columns=-1},
symbolic x coords={tool1, tool2},
xtick=data,
x tick label style={rotate=45,anchor=east},
ymajorgrids,
/tikz/mstyle/.style={draw,red,very thick,text=black},
/tikz/mleft/.style={xshift={-(.5*\pgfplotbarwidth+2.5pt)}},
/tikz/mline/.style={insert path={--+({\pgfplotbarwidth+5pt},0pt)}},
]
\path[mstyle]([mleft]axis cs:tool1,2)[mline]node[right]{$2$};
\path[mstyle]([mleft]axis cs:tool2,3)[mline]node[right]{$3$};
\addplot plot coordinates {(tool1,0) (tool2,2)};
\addplot plot coordinates {(tool1,0) (tool2,0)};
\addplot plot coordinates {(tool1,6) (tool2,6)};
\addplot plot coordinates {(tool1,4) (tool2,2)};
\end{axis}
\end{tikzpicture}
\end{document}[/code]
[img]http://golatex.de/files/gl_stackedplotmark_153.png[/img]
Beachte, dass Du beim Zeichnen der Striche die symbolischen x-Koordinaten verwenden musst. Ist es Absicht, dass Du Kompatibilität zu der recht alten Version 1.10 herstellst? Aktuell ist derzeit 1.14