#!/usr/bin/python3 """Simple matplotlib+numpy program to plot voltage decay in an RC circuit. The ``rcParams`` mentioned here is a coincidence; that’s just what Matplotlib calls its parameters. """ import sys from numpy import linspace, exp from matplotlib.pyplot import plot, xlabel, ylabel, savefig, rcParams def plot_rc(tau, outfilename): rcParams["pdf.use14corefonts"] = True rcParams["ps.useafm"] = True # analogous to use14corefonts for PS/EPS t = linspace(0, tau * 6) plot(t, exp(-t / tau)) xlabel("time (seconds)") ylabel("fraction of initial $V$") savefig(outfilename) if __name__ == '__main__': plot_rc(tau=0.1, outfilename='rc.svg' if len(sys.argv) == 1 else sys.argv[1])