# Plot does not scale correctly

I'm having a hard time trying to center a simple pgfplots.

This is my code:

    \begin{figure}[h!]
\centering
\caption{ Comparação da função tangente hiperbólica em diferentes implementações.}
\vspace{\baselineskip}
\fonte{Próprio autor.}
\label{fig:tanh-plot}
\begin{tikzpicture}[spy using outlines={circle, magnification=3, connect spies}]
\begin{axis}[
xlabel={$x$},
ylabel={$y = \tanh{x}$},
xmin=-3.5, xmax=3.5,
ymin=-1.0, ymax=1.0,
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]

table {plots/tanh-tf.dat};

table {plots/tanh-vhdl.dat};

\coordinate (spypoint) at (axis cs:-.75, -.63);
%\coordinate (spypoint) at (axis cs:0, 0);
\coordinate (magnifyglass) at (axis cs:2, -.2);

\end{axis}

\spy[blue, size=8cm] on (spypoint) in node[fill=white] at (magnifyglass);
\end{tikzpicture}
\end{figure}


Which gives me the following result (I only cropped the bottom part of the page):

How do I center the plot? It seems to have space in the left margin to do so, so why doesn't it?

• The text "Próprio autor." and the plot are on the same line in the same paragraph. – Heiko Oberdiek May 8 '18 at 0:00
• @HeikoOberdiek I guess that was it (?) -- see my answer. Thanks! – gabrieljcs May 8 '18 at 3:18

\vspace{\baselineskip}

after \end{tikzpicture}.