更新:
我想要一个垂直方向下降约 1/3 和 2/3 的图表。当我将其输入到 Texmaker 时,它出现多个错误,包括
Dimension too large
Package PGF Math Error: I cannot calculate the logarithm of '0,0'
(in '{2(0,0)^(3/2)-3(0,0)+1.4}').
甚至独立版也不起作用,那么是包装问题吗?
梅威瑟:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=4.34618291761148cm,y=4.205741626794257cm]
\draw[->,color=black] (-0.1,0) -- (1.97,0);
\foreach \x in {,1}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\draw[color=black] (1.81,0.02) node [anchor=south west] { Order Quantity};
\draw[->,color=black] (0,-0.14) -- (0,2);
\foreach \y in {,1}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt);
\clip(-0.1,-0.14) rectangle (1.97,2);
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+2});
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.7});
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.4});
\draw[line width=1.2pt, smooth,samples=100,domain=0.01:0.6666666666666666] plot(\x,{2*(\x)^(3/2)-3*(\x)+2});
\draw[line width=1.2pt, smooth,samples=100,domain=0.6666666666666666:1.3333333333333333] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.7});
\draw[line width=1.2pt, smooth,samples=100,domain=1.3333333333333333:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.4});
\draw [line width=1.2pt] (0.67,1.09)-- (0.67,0.79);
\draw [line width=1.2pt] (1.33,0.78)-- (1.33,0.48);
\draw (1.01,0.03) node[anchor=north west] {$Q^*$};
\draw (-0.06,0.79) node[anchor=north west] {$C^*$};
\draw (0.01,1.99) node[anchor=north west] {Average Cost per Unit Time};
\end{tikzpicture}
\结束{文档}
答案1
发生这种情况的原因是,domain
图的设置为从 开始0
,其中对数未定义。只需将domain
s 设置为从 开始0.01
或其他较小的值:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=4.34618291761148cm,y=4.205741626794257cm]
\draw[->,color=black] (-0.1,0) -- (1.97,0);
\foreach \x in {,1}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\draw[color=black] (1.81,0.02) node [anchor=south west] { Order Quantity};
\draw[->,color=black] (0,-0.14) -- (0,2);
\foreach \y in {,1}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt);
\clip(-0.1,-0.14) rectangle (1.97,2);
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+2});
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.7});
\draw[dash pattern=on 2pt off 2pt, smooth,samples=100,domain=0.01:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.4});
\draw[line width=1.2pt, smooth,samples=100,domain=0.01:0.6666666666666666] plot(\x,{2*(\x)^(3/2)-3*(\x)+2});
\draw[line width=1.2pt, smooth,samples=100,domain=0.6666666666666666:1.3333333333333333] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.7});
\draw[line width=1.2pt, smooth,samples=100,domain=1.3333333333333333:1.9707826086956564] plot(\x,{2*(\x)^(3/2)-3*(\x)+1.4});
\draw [line width=1.2pt] (0.67,1.09)-- (0.67,0.79);
\draw [line width=1.2pt] (1.33,0.78)-- (1.33,0.48);
\draw (1.01,0.03) node[anchor=north west] {$Q^*$};
\draw (-0.06,0.79) node[anchor=north west] {$C^*$};
\draw (0.01,1.99) node[anchor=north west] {Average Cost per Unit Time};
\end{tikzpicture}
\end{document}