""" creating multiple subplots adapted from: http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/subplot_demo.py """ import numpy as np import matplotlib.pyplot as plt def f(t): s1 = np.cos(2*np.pi*t) e1 = np.exp(-t) return np.multiply(s1,e1) t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) t3 = np.arange(0.0, 2.0, 0.01) fig = plt.figure() ax = fig.add_subplot(211) l = ax.plot(t1, f(t1), 'bo', t2, f(t2), 'k--', markerfacecolor='green') ax.grid(True) ax.set_title('A tale of 2 subplots') ax.set_ylabel('Damped oscillation') ax = fig.add_subplot(212) ax.plot(t3, np.cos(2*np.pi*t3), 'r.') ax.grid(True) ax.set_xlabel('time (s)') ax.set_ylabel('Undamped') fig.show()