1import matplotlib.pyplot as plt
2import numpy as np
3
4fig = plt.figure(figsize=(12, 6))
5
6x = np.arange(0, 10, 0.1)
7y = np.sin(x)
8z = np.cos(x)
9
10ax = fig.add_subplot(121)
11ax2 = fig.add_subplot(122)
12
13ax.set_title('Full view')
14ax.plot(y, color='blue', label='Sine wave')
15ax.plot(z, color='black', label='Cosine wave')
16
17ax2.set_title('Truncated view')
18ax2.plot(y, color='blue', label='Sine wave')
19ax2.plot(z, color='black', label='Cosine wave')
20
21ax2.set_xlim([25, 50])
22
23plt.show()
24