这是我的代码
\usepackage{tikz}
\begin{tikzpicture}
\draw[->] (0,0) -- (6,0) node[anchor=north] {$t[s]$};
\draw[->] (0,0) -- (0,4) node[anchor=east] {$q[C]$};
\draw (0,0) node[anchor=east] {$0$};
\draw[smooth, domain =0:6, samples = 500, color=blue] plot ({\x, 8*e^(-\x)-4*e^(-2*\x)});
\end{tikzpicture}
它返回一个错误。你能告诉我如何修复它吗?
答案1
我认为您正在尝试绘制一条指数曲线。
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={myexp(\x)=8*e^(-\x)-4*e^(-2*\x);}]
\begin{axis}[
axis lines=left,
xlabel=$x$,
ylabel=$y$,
]
\addplot [domain=0:6, samples = 500, color=blue] {myexp(x)};
\end{axis}
\end{tikzpicture}
\end{document}