This rendering:
is produced by:
\documentclass{article}
\usepackage{showframe}
\usepackage{pgfplots}
\begin{document}
\begin{figure}[htb]
\begin{tikzpicture}[trim axis right, trim axis left]
\begin{axis}[
xmin=-3, xmax=3,
ymin=-3, ymax=3,
extra x ticks={-1,1},
extra y ticks={-2,2},
extra tick style={grid=major},
xlabel=This is the first text which is this long,
height=3cm,
width=\textwidth/2, scale only axis
]
\end{axis}
\end{tikzpicture}This is the second text
\end{figure}
\end{document}
How can I trim the bottom of the tikzpicture
so that the baseline of the x-axis label is aligned with the baseline of the surrounding text? I'm aware of the [baseline=...]
argument to tikzpicture
but can't work out how to extract a position from the pgfplot
Note: the actual motivation here is to get a smaller space between the axis label and the figure caption, which the answers here succeed in!