-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
23 lines (18 loc) · 971 Bytes
/
graph.py
File metadata and controls
23 lines (18 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2*np.pi, 2*np.pi, 400);
plt.figure();
plt.figure(figsize=(16, 8));
plt.plot(x, np.sin(x), color="blue", label="sin(x)", linewidth=2);
plt.plot(x, np.cos(x), color="red", label="cos(x)", linewidth=2);
plt.plot(x, np.sin(x)**2, linestyle="--", color="blue", linewidth=2, label="sin²(x)");
plt.plot(x, np.cos(x)**2, linestyle="--", color="red", linewidth=2, label="cos²(x)");
plt.plot(x, (np.cos(x)**2)+(np.sin(x)**2), linestyle=":", color="yellow", linewidth=3, alpha=0.7, label="sin²(x) + cos²(x)");
plt.plot(x, (np.cos(x)**2)-(np.sin(x)**2), linestyle=":", color="orange", linewidth=3, alpha=0.8, label="sin²(x) - cos²(x)");
plt.plot(x, (np.cos(x)**2)*(np.sin(x)**2), linestyle=":", color="purple", linewidth=3, alpha=0.8, label="sin²(x) × cos²(x)");
plt.xlabel("x axes");
plt.ylabel("y axes");
plt.title("sin(x) & cos(x) and operations with them");
plt.legend();
plt.grid();
plt.show();