Lifetimes of an exponential decay

The following program plots the exponential decay described by $y = Ne^{-t/\tau}$ labeled by lifetimes, ($n\tau$ for $n = 0, 1, \cdots$) such that after each lifetime the value of $y$ falls by a factor of $e$.

import numpy as np
import matplotlib.pyplot as plt

# Initial value of y at t=0, lifetime in s
N, tau = 10000, 28
# Maximum time to consider (s)
tmax = 100
# A suitable grid of time points, and the exponential decay itself
t = np.linspace(0, tmax, 1000)
y = N * np.exp(-t/tau)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(t, y)

# The number of lifetimes that fall within the plotted time interval
ntau = tmax // tau + 1
# xticks at 0, tau, 2*tau, ..., ntau*tau; yticks at the corresponding y-values
xticks = [i*tau for i in range(ntau)]
yticks = [N * np.exp(-i) for i in range(ntau)]

# xtick labels: 0, tau, 2tau, ...
xtick_labels = [r'$0$', r'$\tau$'] + [r'${}\tau$'.format(k) for k in range(2,ntau)]
# corresponding ytick labels: N, N/e, N/2e, ...
ytick_labels = [r'$N$',r'$N/e$'] + [r'$N/{}e$'.format(k) for k in range(2,ntau)]


The $x$-axis tick labels have been set to $1, \tau, 2\tau, ...$ and the $y$-axis tick labels to $N, N/e, N/2e, ...$

Note that the length of the sequence of tick labels must correspond to that of the list of tick values required.

Lifetimes of an exponential decay