-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubplots
More file actions
32 lines (26 loc) · 671 Bytes
/
Copy pathsubplots
File metadata and controls
32 lines (26 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import matplotlib.pyplot as plt
import numpy as np
# Sample data
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)
y2 = np.cos(x)
y3 = np.sin(x) * np.cos(x)
# Create a figure with a series of plots
plt.figure(figsize=(12, 4))
plt.subplot(1, 3, 1)
plt.plot(x, y, color='blue')
plt.title('Sine Wave')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.subplot(1, 3, 2)
plt.plot(x, y2, color='green')
plt.title('Cosine Wave')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.subplot(1, 3, 3)
plt.plot(x, y3, color='red')
plt.title('Product of Sine and Cosine')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.tight_layout() # Adjusts subplot params for a tight layout
plt.show()