尺寸过大

尺寸过大

我收到错误“尺寸太大”,但事实并非如此。MWE:

\documentclass[border=1mm]{article}
\usepackage{tikz}

\begin{document}

 \begin{tikzpicture}
  \draw[-latex] (-1,0) -- (12,0);
  \draw[-latex] (0,-1) -- (0,6);
  \foreach \x in {2,4,...,12} 
   \node at (\x,0) [below] {$\x$};
  \foreach \y in {2,4,...,6} 
   \node at (0,\y) [left] {$\y$};
  
  \draw[variable=\t,domain=-1:11,samples=1000,smooth,orange] plot ({\t},{-0.0005*(\t)^5 + (0.0066*(\t)^4) - (0.013*(\t)^3)});
 \end{tikzpicture}


\end{document}

我应该有这样的输出: 在此处输入图片描述

感谢您的帮助

答案1

它说dimension too large因为 TiZ 无法计算您在计算中达到的某个固定点。请改用pgfplots

尺寸太大

\documentclass[border=1mm]{article}

\usepackage{pgfplots}

\begin{document}

    \begin{tikzpicture}
        \begin{axis}[samples=500,domain=-3:11,axis lines=middle,restrict y to domain =-2:6]
            \addplot[very thick,blue   ] plot (\x,{(-(\x)^(5))/2000+8*(\x)^(4)/1200-4*(\x)^(3)/300});
        \end{axis}
    \end{tikzpicture}

\end{document}

编辑:新解决方案-TiZ 解决方法

您计算中的问题是高幂。为了解决这个问题,可以将数字缩小为幂:(0.0005^(1/5)*(\t))^5而不是0.0005*(\t)^5。以下是完整代码:

\documentclass{article}
\usepackage{tikz}

\begin{document}

    \begin{tikzpicture}
        \draw[very thin, cyan!50] (-1,-4) grid (12,6);
        \draw[-latex] (-1,0) -- (12,0);
        \draw[-latex] (0,-4) -- (0,6);
        \foreach \x in {2,4,...,12} 
            \node at (\x,0) [below] {$\x$};
        \foreach \y in {2,4,...,6} 
            \node at (0,\y) [left] {$\y$};
        
        \draw[variable=\t,domain=-1:11,samples=1000,smooth,orange,line width=1pt] plot ({\t},{-(0.0005^(1/5)*(\t))^5 + (0.0066^(1/4)*(\t))^4 - (0.013^(1/3)*(\t))^3});
    \end{tikzpicture}

\end{document}

钛

答案2

PGFPlot 解决方案:

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=13cm, height=7cm,
axis lines=middle,
xmin=-1, xmax=12,
ymin=-1, ymax=6,
]
\addplot[variable=\t, domain=-1:11, samples=100, smooth, orange] ({\t},{-0.0005*(\t)^5 + (0.0066*(\t)^4) - (0.013*(\t)^3)});
\end{axis}
\end{tikzpicture}
\end{document}

橙色曲线图

答案3

您可以使用pgfmath-xfp

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfmath-xfp}

\begin{document}

\begin{tikzpicture}
  \pgfmxfpdeclarefunction{f}{1}{-0.0005*(#1)^5 + (0.0066*(#1)^4) - (0.013*(#1)^3)}
  \draw[-latex] (-1,0) -- (12,0);
  \draw[-latex] (0,-1) -- (0,6);
  \foreach \x in {2,4,...,12} \node at (\x,0) [below] {$\x$};
  \foreach \y in {2,4,...,6}  \node at (0,\y) [left] {$\y$};
  \draw[
    variable=\t,
    domain=-1:11,
    samples=1000,
    smooth,
    orange
  ] plot ({\t},{f(\t)});
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容