PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tikz gestapeltes Säulendiag.: Legendensymbol-Problem



sailor79
21-05-2011, 09:14
Guten Morgen zusammen,

habe in pgfpltos/Tikz das Problem bei gestapeltem Säulendiagramm, dass in der Legende nicht wie sonst ein Balkensymbol, sondern eine Linie gezeichnet wird. Habe keine Idee,wie das kommt.
Im Anhang eine pdf mit dem (ungewollten Ergebnis) und ein Bild soll2.png angefügt.

Hier der Code für das Minimalbeispiel:



\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{pgfplots}

\begin{document}

\pgfplotsset{width=18cm,compat=1.3}
\begin{tikzpicture}[scale=0.72]

\begin{axis}[
xticklabel style={rotate=45,anchor=near xticklabel},
xtick={1,2,3,4,5,6,7,8,9,10,11},
xticklabels={T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11},
ylabel=ylabel,
xlabel=xlabel,
%enlargelimits=0.07,
legend style={at={(0.03,0.96)},
anchor=north west,legend columns=3},
ybar stacked,
%ybar=0pt,
bar width=12pt,
nodes near coords,
ymin=0,
ymax=22,
]

\addplot coordinates {
(1,0)
(2,13)
(3,11)
(4,16)
(5,7)
(6,5)
(7,12)
(8,0)
(9,6)
(10,0)
(11,0)};

\addplot coordinates {
(1,2)
(2,2)
(3,2)
(4,2)
(5,2)
(6,2)
(7,2)
(8,2)
(9,2)
(10,2)
(11,2)};
\legend{Anzahl 1,zzgl. 2,}

\end{axis}
\end{tikzpicture}

\end{document}


Kann mir wer helfen? Vielen Dank schonmal

Sailor

esdd
21-05-2011, 15:00
Hallo,

auch hier habe ich in die Doku geschaut und dann wieder xticks align=outside und ybar legend bei den axis Optionen ergänzt.


\documentclass{report}
\usepackage{pgfplots}

\begin{document}
\pgfplotsset{width=18cm,compat=1.3}
\begin{tikzpicture}[scale=0.72]
\begin{axis}[%
xticklabel style={rotate=45,anchor=near xticklabel},%
xtick={1,2,3,4,5,6,7,8,9,10,11},%
xtick align=outside,%
xticklabels={T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11},%
ylabel=ylabel,%
xlabel=xlabel,%
legend style={at={(0.03,0.96)},anchor=north west,legend columns=-1},%
ybar legend,
ybar stacked,bar width=12pt,%
nodes near coords,%
ymin=0,ymax=22,%
]
\addplot coordinates {(1,0) (2,13) (3,11) (4,16) (5,7) (6,5) (7,12)%
(8,0) (9,6) (10,0) (11,0)};
\addplot coordinates {(1,2) (2,2) (3,2) (4,2) (5,2) (6,2) (7,2)%
(8,2) (9,2) (10,2) (11,2)};
\legend{Anzahl 1,zzgl. 2,}
\end{axis}
\end{tikzpicture}
\end{document}
Gruß
Elke

sailor79
21-05-2011, 15:58
Danke Elke !:)