7

When compiling the code

\documentclass{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}
        [   
            x label style={rotate=45},
            xlabel=$x$,
            y label style={rotate=45},
            ylabel=$y$,
            z label style={rotate=45,at={(0,0.5)}},
            zlabel=$z$,
            axis lines=center,
            view={45}{20}
        ]
            \addplot3[surf,opacity=0.5] {x^2-y^2};              
        \end{axis}
    \end{tikzpicture}
\end{document}

the axis label style in the axis environment options do not seem to work.

The resulting picture looks like

Here you can see that although rotate=45 is set for each of the labels, they're not in the picture. Also the at={(0,0.5)} in z label style does not seem to work. But if I remove the command axis lines=center everything works fine.

How do I get these options to also work when using axis lines=center?

3
  • 4
    axis lines=center also sets x label style, so it overwrites the options you set in x label style. Move axis lines=center to the start of your options list, and it will work as expected
    – Jake
    Mar 23, 2015 at 17:12
  • @Jake Indeed, works like a charm. Do you want to make an answer out of it or should I do it for you?
    – Adriaan
    Mar 23, 2015 at 22:03
  • 2
    The close vote because this is "unclear" seems misguided given that Jake has answered the question in the comments.
    – user30471
    Apr 14, 2015 at 12:48

1 Answer 1

5

Like Jake states in the comments, axis lines center also sets x label style, so it overwrites the options you set in x label style. Moving axis lines=center to the start of the options list solves the problem:

\documentclass{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}
        [   
            axis lines=center, % NOW AT THE TOP INSTEAD OF AT THE BOTTOM OF THE OPTIONS LIST.
            x label style={rotate=45},
            xlabel=$x$,
            y label style={rotate=45},
            ylabel=$y$,
            z label style={rotate=45,at={(0,0.5)}},
            zlabel=$z$,
            view={45}{20}
        ]
            \addplot3[surf,opacity=0.5] {x^2-y^2};              
        \end{axis}
    \end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .