Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a664c8a

Browse files
committed
adding both methods how to generate multiple plots
1 parent 1e58203 commit a664c8a

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

examples/subplots_axes_and_figures/subplot.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,34 @@
2626
ax2.set_ylabel('Undamped')
2727

2828
plt.show()
29+
30+
#############################################################################
31+
#
32+
#
33+
# Alternative Method For Creating Multiple Plots
34+
# """"""""""
35+
#
36+
# Subplots can also be generated using `subplot()` as in the following example:
37+
#
38+
39+
import numpy as np
40+
import matplotlib.pyplot as plt
41+
42+
43+
x1 = np.linspace(0.0, 5.0)
44+
x2 = np.linspace(0.0, 2.0)
45+
46+
y1 = np.cos(2 * np.pi * x1) * np.exp(-x1)
47+
y2 = np.cos(2 * np.pi * x2)
48+
49+
plt.subplot(2, 1, 1)
50+
plt.plot(x1, y1, 'o-')
51+
plt.title('A tale of 2 subplots')
52+
plt.ylabel('Damped oscillation')
53+
54+
plt.subplot(2, 1, 2)
55+
plt.plot(x2, y2, '.-')
56+
plt.xlabel('time (s)')
57+
plt.ylabel('Undamped')
58+
59+
plt.show()

0 commit comments

Comments
 (0)