PGFplots 3D:轴标签放置在轴的“中间”,而不是尖端

PGFplots 3D:轴标签放置在轴的“中间”,而不是尖端

我想使用“中心”样式的轴,并将轴的标签放在箭头附近。它在 2D 中有效,但在 3D 中,x 和 y 轴的标签放在非常奇怪的地方。请参阅图片作为示例。这不是 1.8 版之前的 PGFplot 错误,因为我有 1.11 版。我的代码是

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

\pgfplotsset{
  compat=1.11,%
    axis lines=center,%
    tick align=outside,%
    xlabel style={anchor=south west},%
    ylabel style={anchor=south west},%
    zlabel style={anchor=south west},%
}

\begin{document}
\begin{tikzpicture}

\begin{axis} [
  name=A,
  xlabel={$x$}, ylabel={$y$}
]
\addplot+ coordinates { (1,1) (2,2) };
\end{axis}

\begin{axis} [
  at={(A.south)},
  anchor=north,
  yshift=-1cm,
  xlabel={$x$}, ylabel={$y$}, zlabel={$z$} ]
\addplot3+ coordinates { (1,1,1) (2,2,2) };
\end{axis}
\end{tikzpicture}
\end{document}

我做错了什么?

平均能量损失

答案1

这很可能是因为“竞争条件”。这意味着这是一个何时执行的问题。因此,如果您将键值直接放入相应的axis选项中或将它们放入every axis/.append style中,您将获得所需的输出\pgfplotsset

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        % use `compat' level 1.8 or higher
        compat=1.8,
        % just put all the options in here and it will work as expected
        every axis/.append style={
            axis lines=center,
            xlabel style={anchor=south west},
            ylabel style={anchor=south west},
            zlabel style={anchor=south west},
            tick align=outside,
        },
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis} [
            name=A,
            xlabel={$x$},
            ylabel={$y$},
        ]
            \addplot+ coordinates { (1,1) (2,2) };
        \end{axis}

        \begin{axis} [
            at={(A.south)},
            anchor=north,
            yshift=-1cm,
            xlabel={$x$},
            ylabel={$y$},
            zlabel={$z$},
%            % -----------------------------------
%            % putting the options directly here
%            % would (also) lead to the expected
%            % result
%            axis lines=center,
%            xlabel style={anchor=south west},
%            ylabel style={anchor=south west},
%            zlabel style={anchor=south west},
%            tick align=outside,
%            % -----------------------------------
        ]
            \addplot3+ coordinates { (1,1,1) (2,2,2) };
        \end{axis}
    \end{tikzpicture}
\end{document}

该图显示了上述代码的结果

相关内容