修复了使用 Gnuplot 绘制图形时不使用 tikz 包时出现的问题。
代码1:需要 gnuplot
\documentclass[tikz,border=3.14mm]{standalone}
\def\A{2.5}
\def\V{0.8}
\def\q{0.8}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (5,0) node[below] {$x$};
\draw[->] (0,0) -- (0,3) ;
\draw[color=green!30!black, very thick, smooth]plot[id=x, domain=0:5] function{\A*(1-exp(-log(2)*(x)/\V))};
\draw[dashed] (0,\A) node[left] {$\theta_a$} -- (5,\A);
\draw[dashed, color=red] (0,\q*\A)node[left] {$q\theta_a$} -- (5,\q*\A);
\draw[dashed, color=red] (\V+1.07,0)node[below] {$\vartheta_q$} -- ++(0,3);
\draw[dashed] (-0.2,-0.4) -- (1.5,3);
\end{tikzpicture}
\end{document}
输出:绘制函数
\draw[color=green!30!black, very thick, smooth]plot[id=x, domain=0:5] function{\A*(1-exp(-log(2)*(x)/\V))};
代码2:没有 gnuplot
\documentclass[tikz,border=3.14mm]{standalone}
\def\A{2.5}
\def\V{0.8}
\def\q{0.8}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (5,0) node[below] {$x$};
\draw[->] (0,0) -- (0,3) ;
\draw[color=green!30!black, very thick, smooth,domain=0.1:5] plot (\x,{\A*(1-exp(-log2(\x)/\V))});
\draw[dashed] (0,\A) node[left] {$\theta_a$} -- (5,\A);
\draw[dashed, color=red] (0,\q*\A)node[left] {$q\theta_a$} -- (5,\q*\A);
\draw[dashed, color=red] (\V+1.07,0)node[below] {$\vartheta_q$} -- ++(0,3);
\draw[dashed] (-0.2,-0.4) -- (1.5,3);
\end{tikzpicture}
\end{document}
输出:将函数更改为
\draw[color=green!30!black, very thick, smooth,domain=0.1:5] plot (\x,{\A*(1-exp(-log2(\x)/\V))});
笔记:我正在尝试不使用 gnuplot 进行绘图。感谢您的帮助。
转换函数有问题吗!?
答案1
在代码2的函数中你应该改为log2(\x)
使用ln(2)*(\x)
自然对数:
\documentclass[tikz,border=3.14mm]{standalone}
\def\A{2.5}
\def\V{0.8}
\def\q{0.8}
\begin{document}
\begin{tikzpicture}
\draw[->] (0,0) -- (5,0) node[below] {$x$};
\draw[->] (0,0) -- (0,3) ;
\draw[color=green!30!black, very thick, smooth,domain=0.1:5] plot (\x,{\A*(1-exp(-ln(2)*(\x)/\V))});
\draw[dashed] (0,\A) node[left] {$\theta_a$} -- (5,\A);
\draw[dashed, color=red] (0,\q*\A)node[left] {$q\theta_a$} -- (5,\q*\A);
\draw[dashed, color=red] (\V+1.07,0)node[below] {$\vartheta_q$} -- ++(0,3);
\draw[dashed] (-0.2,-0.4) -- (1.5,3);
\end{tikzpicture}
\end{document}