\documentclass[tikz, convert = false]{standalone}
\usepackage[utf8]{inputenx}% http://ctan.org/pkg/inputenx
% Euler for math | Palatino for rm | Helvetica for ss | Courier for tt
\renewcommand{\rmdefault}{ppl}% rm
\linespread{1.05}% Palatino needs more leading
\usepackage[scaled]{helvet}% ss // http://ctan.org/pkg/helvet
\usepackage{courier}% tt // http://ctan.org/pkg/courier
\usepackage{eulervm} % http://ctan.org/pkg/eulervm
% a better implementation of the euler package (not in gwTeX)
\normalfont%
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\usepackage{textcomp}% http://ctan.org/pkg/textcomp
\usepackage{pgfplots}
\pgfplotsset{compat = 1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymax = 1.15,
ymin = 0,
xmin = 0,
xmax = 20,
ytick = {0, .63, 1},
xtick = {0},
axis x line = center,
axis y line = left,
xlabel style = {below = 2ex},
xlabel = {$t$},
ylabel = {$y(t)$},
]
\addplot[blue] gnuplot[id = exp, domain = 0:20] {1 - exp(-x/5)};
\end{axis}
\end{tikzpicture}
\end{document}
我想在 y = 1 处添加一条虚线水平渐近线。
我想从 y = .63 到函数的交点画一条虚线。然后我想从该交点画到 x 轴并将其标记为 tau。
pgfplots
在使用时我该如何做到这一点gnuplot
?
此外,我觉得情节不太连贯。我可以添加更多内容来让情节更顺畅吗?
答案1
- 看如何在绘图中添加零线?
- 找到函数的反函数,并代入其值。
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.9}
\pgfmathsetmacro\result{-ln(1-0.63)*5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymax = 1.15,
ymin = 0,
xmin = 0,
xmax = 20,
ytick = {0, .63, 1},
xtick = {0},
axis x line = center,
axis y line = left,
xlabel style = {below = 2ex},
xlabel = {$t$},
ylabel = {$y(t)$},
extra x ticks={\result},
extra x tick labels=$\tau$
]
\addplot[blue, samples=50, smooth] gnuplot[id = exp, domain = 0:20] {1 - exp(-x/5)};
\draw (axis cs:0,1) -- ({axis cs:0,1}-|{rel axis cs:1,0});
\draw [densely dashed] (axis cs:0,0.63) -| (axis cs:\result,0);
\end{axis}
\end{tikzpicture}
\end{document}