von chaoscrack » Di 17. Jun 2014, 11:47
Hallo
Ich möchte ein Balkendiagramm mit zwei Daten abgebildet auf der linken Y-Achse und eine Linie abgebildet auf der rechten Y-Achse machen. Dies klappt auch ganz gut. Leider bringe ich aber die Legende nicht auf einen Nenner.
Kennt jemand eine Möglichkeit die Legende ausserhalb der Achsenumgebung zu erstellen?
Hier noch was ich schon zusammengebastelt habe:
\begin{tikzpicture}
\footnotesize
\begin{axis}[height=4cm, width=7cm,
scale only axis,
xmin=0.5, xmax=4.5, ymin=400, ymax=1600,
axis x line=bottom,
xtick={0.5, 1, 2, 3, 4, 4.5}, ytick={400,600,800,1000,1200,1400,1600},
xticklabels={,2009, 2010, 2011, 2012, },
axis y line=left, ylabel=Patienten in 1'000,
ymajorgrids=true,
legend style={cells={anchor=west},name={leg1},at={(1.25,0.65)},anchor=north west,draw=none},
ybar,
bar width=7pt]
\addplot[red, fill=red!50] plot coordinates
{(01, 1328) (02, 1345) (03, 1364) (04, 1340)};
\addplot[blue, fill=blue!50] plot coordinates
{(01, 536) (02, 560) (03, 573) (04, 567)};
\legend{Total Eintritte, via Notfall}
\end{axis}
\begin{axis}[height=4cm, width=7cm,
scale only axis,
axis x line=none,
xmin=0.5, xmax=4.5, ymin=39, ymax=45,
xtick={0.5, 1, 2, 3, 4, 4.5}, ytick={39,40,41,42,43,44,45},
axis y line=right, ylabel=Anteil Notfall in \%,
legend style={cells={anchor=west},name={leg2},at={(leg1.south west)},anchor=north west,draw=none}]
\addplot[green,mark=*] plot coordinates
{(01, 40.4) (02, 41.6) (03, 42) (04, 42.3)};
\addlegendentry{in Prozent}
\end{axis}
\end{tikzpicture}
Danke für die Hilfe und allfällige Vereinfachungen.
Hallo
Ich möchte ein Balkendiagramm mit zwei Daten abgebildet auf der linken Y-Achse und eine Linie abgebildet auf der rechten Y-Achse machen. Dies klappt auch ganz gut. Leider bringe ich aber die Legende nicht auf einen Nenner.
Kennt jemand eine Möglichkeit die Legende ausserhalb der Achsenumgebung zu erstellen?
Hier noch was ich schon zusammengebastelt habe:
[code]
\begin{tikzpicture}
\footnotesize
\begin{axis}[height=4cm, width=7cm,
scale only axis,
xmin=0.5, xmax=4.5, ymin=400, ymax=1600,
axis x line=bottom,
xtick={0.5, 1, 2, 3, 4, 4.5}, ytick={400,600,800,1000,1200,1400,1600},
xticklabels={,2009, 2010, 2011, 2012, },
axis y line=left, ylabel=Patienten in 1'000,
ymajorgrids=true,
legend style={cells={anchor=west},name={leg1},at={(1.25,0.65)},anchor=north west,draw=none},
ybar,
bar width=7pt]
\addplot[red, fill=red!50] plot coordinates
{(01, 1328) (02, 1345) (03, 1364) (04, 1340)};
\addplot[blue, fill=blue!50] plot coordinates
{(01, 536) (02, 560) (03, 573) (04, 567)};
\legend{Total Eintritte, via Notfall}
\end{axis}
\begin{axis}[height=4cm, width=7cm,
scale only axis,
axis x line=none,
xmin=0.5, xmax=4.5, ymin=39, ymax=45,
xtick={0.5, 1, 2, 3, 4, 4.5}, ytick={39,40,41,42,43,44,45},
axis y line=right, ylabel=Anteil Notfall in \%,
legend style={cells={anchor=west},name={leg2},at={(leg1.south west)},anchor=north west,draw=none}]
\addplot[green,mark=*] plot coordinates
{(01, 40.4) (02, 41.6) (03, 42) (04, 42.3)};
\addlegendentry{in Prozent}
\end{axis}
\end{tikzpicture}
[/code]
Danke für die Hilfe und allfällige Vereinfachungen.