Hallo,
dann braucht auch die erste axis-Umgebung die Info, dass es insgesamt 3 Plots sind. Da die Balken symmetrisch um den jeweiligen x-Wert verteilt werden, geht die Gesamtzahl der Plots in die Berechnung der Verschiebungen ein.
Du könntest einfach leere \addplots als Platzhalter einfügen, erhälst dafür dann aber mindestens Warnungen und ich weiß nicht, ob das weitere Nebenwirkungen hat.
Code:
\documentclass{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{every axis/.style={ybar, scale only axis, xmin=0, xmax=8, ymin=0}}
%Linke Achse (Primärachse)
\begin{axis}[axis y line*=left, ymax=10]
\addplot coordinates {(1,3)(5,1)}; %Zug
\addplot coordinates {(1,5)(6,2)}; %Biege
\addplot coordinates {};
\end{axis}
%
%Rechte Achse (Sekachse)
\begin{axis}[axis y line*=right, axis x line=none, ymax=150]
\addplot coordinates {};
\addplot coordinates {};
\addplot coordinates {(1,100)(7,120)}; %Druck
\end{axis}
\end{tikzpicture}
\end{document}
Sauberer ist es dann wahrscheinlich bar shift direkt anzugeben:
Code:
\documentclass{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\pgfkeyssetvalue{/mykeys/bardistance}{2pt}% Abstand zwischen den Balken beim gleichen x-Wert
\pgfplotsset{every axis/.style={ybar, scale only axis, xmin=0, xmax=8, ymin=0}}
%Linke Achse (Primärachse)
\begin{axis}[axis y line*=left, ymax=10]
\addplot+[bar shift=-\pgfplotbarwidth-\pgfkeysvalueof{/mykeys/bardistance}] coordinates {(1,3)(5,1)}; %Zug
\addplot+[bar shift=0] coordinates {(1,5)(6,2)}; %Biege
\end{axis}
%
%Rechte Achse (Sekundärachse)
\begin{axis}[axis y line*=right, axis x line=none, ymax=150]
\pgfplotsset{cycle list shift=2}
\addplot+[bar shift=\pgfplotbarwidth+\pgfkeysvalueof{/mykeys/bardistance}] coordinates {(1,100)(7,120)}; %Druck
\end{axis}
\end{tikzpicture}
\end{document}
Vielleicht gibt es aber noch bessere Lösungen dafür.
Gruß
Elke
Lesezeichen