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.


      \begin{axis}[legend pos=outer north east]
      \addplot [domain=0:pi] {sin(deg(x))};
      \addplot [domain=0:pi] {sin(deg(x))};
      \legend{longlonglongplotname, plotname}
  • \begin{tikzpicture}[trim axis right,trim axis left]? Jun 7, 2016 at 17:43
  • Ah, applying it to the tikzpicture environment did the trick. I tried only to add it to the axis Jun 7, 2016 at 17:44
  • Makes a difference when I tested here. Note this applies to the tikzpicture environment, not the axis. Jun 7, 2016 at 17:45
  • 1
    You're welcome. I see a question that is essentially the same, and with the same answer, was posted earlier, so I will vote to close this a duplicate. Jun 7, 2016 at 18:08


Browse other questions tagged .