You are reading an old version of the documentation (v2.1.1). For the latest version see https://matplotlib.org/stable/gallery/pyplots/pyplot_two_subplots.html
matplotlib
Fork me on GitHub


Travis-CI:

Related Topics

This Page

Pyplot Two SubplotsΒΆ

../../_images/sphx_glr_pyplot_two_subplots_001.png
import numpy as np
import matplotlib.pyplot as plt

def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)

t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)

plt.figure(1)
plt.subplot(211)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')

plt.subplot(212)
plt.plot(t2, np.cos(2*np.pi*t2), 'r--')
plt.show()

Total running time of the script: ( 0 minutes 0.033 seconds)

Gallery generated by Sphinx-Gallery