0

Note: This was a bug and has been fixed

This has been answered by Christian. It's a bug that had been resolved in pgfplots 1.8. I've updated my pgfplots and am now running 1.9.

Similar Question

BTW, the y dir=reverse thing was just an experiment as I was learning how to control the orientation of the axes.

Original Question

I'm using \addplot3, I have set axis lines=middle, and the axis labels, using xlabel={$x$} and so on, are haywire. The x is almost in the right place but the z and the y sit on top of each other in the top right hand corner, miles away from the actual graph.

In the output picture below you can clearly see what I've described above.

MWE

Output

\documentclass{standalone}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{mathtools}

\begin{document}
%
\par\begin{tikzpicture}
%
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    axis lines=middle, axis on top,
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    y dir=reverse,
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};
%
\end{axis}
%
\end{tikzpicture}
%
\end{document}
2

1 Answer 1

2

This is the output of a bug which has been fixed in pgfplots version 1.8.

In order to remain compatible with the various workarounds proposed by end-users before version 1.8, you have to enable the bugfix by means of \pgfplotsset{compat=1.8} in the preamble:

\documentclass{standalone}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{mathtools}

\pgfplotsset{compat=1.8}

\begin{document}
%
\par\begin{tikzpicture}
%
\begin{axis}[
    xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    axis lines=middle, axis on top,
    xtick={-2,2}, ytick={-2,2},ztick={16,32},
    y dir=reverse,
    enlargelimits=true
    ]
\addplot3[surf, thick, color=green, domain=-4:4] {x^2+y^2};
%
\end{axis}
%
\end{tikzpicture}
%
\end{document}

enter image description here

So, in order to fix the example, you have to write \pgfplotsset{compat=1.8} . This will fail if your version is too old. The current stable is 1.9.

5
  • I just upgraded to 1.9. You recommend against newest, but that leaves one having to come back and update compat=x.y in one's projects, several times, over a long period of time. I realise that if the project originally worked there's no need, but that's not always the case. Plenty of my projects get reused and improved. But, it's not a big deal if there really is no better alternative. What would you consider a valid use of compat=newest, if there is one? Oct 20, 2013 at 2:07
  • It seems that my question has been deemed unworthy. I get most of my answers from searching the site, but I had searched comprehensively for this one. Okay, I eventually found one that was close, where you could see the labels were messed up but the fix has ended up with a different result to what you've shown here. So, I will continue with this question and add an update to it. Cheers Oct 20, 2013 at 2:20
  • Oh, the question is worthy enough. If not, you could add links to related questions or even duplicates. Oct 20, 2013 at 10:51
  • I realize that you edited your question to pose a couple of follow-up questions. Could you revert that edit and generate new, isolated questions? This would make it considerably easier for the audience (me included) to see which parts have been addressed by which answers. It also allows to accept answers if they addressed your issue. Oct 20, 2013 at 10:52
  • Regarding "valid uses of compat=newest": please pose an isolated question for that one as well. I believe others have been wondering as well and would not see answers here deep in some comment. Oct 20, 2013 at 10:54

You must log in to answer this question.

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