[Tex/LaTex] How to adjust position of axis labels and ticklabels in 3D pgfplots automatically/dynamically

3daxispgfplotstikz-pgf

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}

enter image description here

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}

enter image description here

Best Answer

You can use the axis options:

  • xticklabel pos=right
  • yticklabel pos=right
  • zticklabel pos=right

This MWE draws your second graph:

\documentclass{standalone}
\usepackage{pgfplots}    
\pgfplotsset{compat=newest}


\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel=Hello,
            ylabel=Bye,
            xticklabel pos=right,
            %yticklabel pos=right,
            %zticklabel pos=right,
        ]
            \addplot3[
                surf,
                samples = 10,
            ]
            {y};
        \end{axis}
    \end{tikzpicture}
\end{document}