[Tex/LaTex] How to center a pgfplot?

horizontal alignmentpgfplots

I am trying to center a graph made with pgfplots with \centering. If I put \centering within a group to limit its scope, the graph does not get centered. If I don't limit the scope of \centering, then everything gets centered.


This text should not be centered, but the graph should be.

% \begingroup
            \addplot coordinates { (0, 0) (1, 1)};
% \endgroup

This text should not be centered.

Best Answer

There is nothing special about tikzpicture here you would see the same with

{\centering X}

\centering works by setting the paragraph parameters, so if you close the group before the paragraph ends then nothing happens. You can use



To centre an X (or a tikzpicture). Or more naturally use


which also adds some vertical space.

Related Question