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}

顯示上述程式碼結果的圖像

相關內容