“隐藏轴”忽略“ymax”

“隐藏轴”忽略“ymax”

在下面的 MWE 中,当我的轴具有属性时hide axisyminymax属性将被完全忽略。我知道我可以添加手册\vskip,但此图是 Beamer 演示的一部分,该演示逐一显示图,我想修复图形的轴限制,以便所有图都具有相同的尺寸。

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

\begin{document}
    \begin{tikzpicture}
      \begin{axis}[scale=1.5, mark=none, xmin=-1,xmax=1,
        ymin=-1, ymax=1, samples=100, 
        hide axis % Comment this to lower the text below 
        ]
        \plot[domain=-1:1] {x^2};
      \end{axis}
    \end{tikzpicture}


    This should be much lower
\end{document}

答案1

这是一个已知的“问题”,最早出现在 PGFPlots v1.8 中。(大多数人都想要“新”的行为,所以它被认为是特征) 您可以通过添加选项来“撤消”此compat/BB=1.7操作,以避免在此特定图中出现这种情况,或者如果您想要在所有图中避免这种情况,则可以axis添加全局选项。\pgfplotsset

% used PGFPlots v1.15
\documentclass[border=5pt,varwidth]{standalone}
\usepackage{pgfplots}
    % the "problem" occurs for `compat=1.8' or higher
    \pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        compat/BB=1.7,      % <-- added
        scale=1.5,
        xmin=-1,    xmax=1,
        ymin=-1,    ymax=1,
        samples=101,
        hide axis,          % Comment this to lower the text below
        mark=none,
    ]
        \addplot [domain=-1:1] {x^2};
    \end{axis}
\end{tikzpicture}

    This should be much lower
\end{document}

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

相关内容