how can I adjust the position of the axis label
and ticklabels
automatically and dynamically in a pgfplots
? Currently I am always shifting them by a specified distance in centimeters.
But on this way, I always have problems when changing the height
and width
of the plot.
Here are two minimal working examples from Latex
with the results I am expecting.
It would be great if the solutions works for all x
, y
and z axis
.
Thank you.
First:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=Hello,
ylabel=Bye,
]
\addplot3[
surf,
samples = 10,
]
{y};
\end{axis}
\end{tikzpicture}
\end{document}
Second:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=Hello,
ylabel=Bye,
xlabel style = {xshift=3cm,yshift=6.2cm},
xticklabel style = {xshift=2.5cm,yshift=5.5cm},
]
\addplot3[
surf,
samples = 10,
]
{y};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
You can use the axis options:
xticklabel pos=right
yticklabel pos=right
zticklabel pos=right
This MWEÂ draws your second graph: