I tried a lot around with setting anchors in the plot, but I couldn't manage to center the plot correctly.
In this example the bounding box of plot and legend gets centered, but I want the plot centered, ignoring the legend.
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\centering
\begin{tikzpicture}
\begin{axis}[legend pos=outer north east]
\addplot [domain=0:pi] {sin(deg(x))};
\addplot [domain=0:pi] {sin(deg(x))};
\legend{longlonglongplotname, plotname}
\end{axis}
\end{tikzpicture}
\end{document}
\begin{tikzpicture}[trim axis right,trim axis left]? – Torbjørn T. Jun 07 '16 at 17:43tikzpictureenvironment did the trick. I tried only to add it to theaxis– fritz-johann Jun 07 '16 at 17:44tikzpictureenvironment, not theaxis. – Torbjørn T. Jun 07 '16 at 17:45