I'd like to add slopes to a function I've plotted that is similar to the following figure that I drew using asymptote. I'd like to remove asymptote dependency from my document by using pgfplots/tikz.
To get started I put a simple pgfplots script together (see below) but now need to figure out how to add the slopes (preferable by computing them, since if the function changes the slope can change).
In asymptote I did the following:
real dydt = 5*exp(-x); // derivative of f()
real theta = atan (dydt);
dx = 0.8*cos (theta);
draw (Scale((x-dx, f(x)-dydt*dx))--Scale((x+dx, f(x)+dydt*dx)), blue+linewidth(1.2));
I presume something similar can be done with pgfplots/tikz?
\documentclass{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
xmin = 0, xmax = 5,
ymin = 0, ymax = 5,
xlabel = Time,
ylabel = Concentration of Product
]
\addplot [red,thick,domain=0:5, samples=100]{5 - 5*exp(-1.0*x)};
\node at (axis cs:3,3) {Slope = rate of change};
\draw[fill=blue](axis cs:0,{5 - 5*exp(-1.0*0)}) circle[blue, radius=6];
\draw[fill=blue](axis cs:1,{5*(1 - exp(-1.0*1))}) circle[blue, radius=6];
\draw[fill=blue](axis cs:2,{5*(1 - exp(-1.0*2))}) circle[blue, radius=6];
\end{axis}
\end{tikzpicture}
\end{document}