pgfplots 错误:尺寸太大

pgfplots 错误:尺寸太大

我正在尝试生成 LaTeX pgfplot:

\begin{tikzpicture}
\begin{axis}[
xmin=.2,xmax=.5,
ymin=-.00000000000000001,ymax=.00000000000000001,
xlabel=Distance a (nm),
ylabel=Force F (mJ/nm)
]
\addplot[color=black][domain=.2:.5]{(((6.42*10^(-22))*6)/(x^7))-(((1.02*10^(-25))*13)/(x^14))};
\addplot[color=red][domain=.2:.5]{(((6.42*10^(-22))*6)/(x^7))};
\addplot[color=blue][domain=.2:.5]{-(((1.02*10^(-25))*13)/(x^14))};

\end{axis}
\end{tikzpicture}

这会产生错误“尺寸太大”。可能是什么问题?

答案1

domain错误是由于“缩放”问题引起的,当您将值更改为接近整个图中“可见”的范围时,可以避免该错误。因此,只需缩小范围domain即可0.3:0.5避免错误。

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        compat=1.3,
    }
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=.2,xmax=.5,
        ymin=-1e-17,
        ymax=+1e-17,
        xlabel=Distance a (nm),
        ylabel=Force F (mJ/nm),
        % ---------------------------------------------------------------------
        % changed `domain' to "visible" part of the plots to avoid
        % the "dimension to large" error
        domain=0.3:0.5,
        % ---------------------------------------------------------------------
        % added `smooth' so the plots look better
        smooth,
    ]
        \addplot [color=black] {(((6.42*10^(-22))*6)/(x^7))-(((1.02*10^(-25))*13)/(x^14))};
        \addplot [color=red]   {(((6.42*10^(-22))*6)/(x^7))};
        \addplot [color=blue]  {-(((1.02*10^(-25))*13)/(x^14))};
    \end{axis}
\end{tikzpicture}
\end{document}

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

相关内容