PGFPlots 和 gnuplot:如何添加渐近线(不是数字的 xtick)以及可以使用交点吗?

PGFPlots 和 gnuplot:如何添加渐近线(不是数字的 xtick)以及可以使用交点吗?
\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}
  1. 我想在 y = 1 处添加一条虚线水平渐近线。

  2. 我想从 y = .63 到函数的交点画一条虚线。然后我想从该交点画到 x 轴并将其标记为 tau。

pgfplots在使用时我该如何做到这一点gnuplot

此外,我觉得情节不太连贯。我可以添加更多内容来让情节更顺畅吗?

在此处输入图片描述

答案1

  1. 如何在绘图中添加零线?
  2. 找到函数的反函数,并代入其值。

\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}

相关内容