2
\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. I would like to add a dashed horizontal asymptote at y = 1.

  2. I would like to draw a dashed line from y = .63 to the intersection of the function. Then I would like to draw from that intersection to the x axis and label it tau.

How can I do this in pgfplots when using gnuplot?

Additionally, the plot seems choppy to me. Can I add more points to smooth it out?

enter image description here

giordano
  • 8,486
dustin
  • 18,617
  • 23
  • 99
  • 204

1 Answers1

7
  1. See How can I add a zero line to a plot?
  2. Find the inverse of the function, plug in the value.

\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}
Jake
  • 232,450