praktikum_wissenschaftliche.../uebung_01/exercise_2a.py

25 lines
612 B
Python
Raw Normal View History

2023-11-22 18:51:30 +00:00
import numpy as np
import matplotlib.pyplot as plt
# x = np.linspace(0, 2 * np.pi, 100)
x_1 = np.arange(0, 2 * np.pi, 1)
x_0_5 = np.arange(0, 2 * np.pi, 0.5)
x_0_1 = np.arange(0, 2 * np.pi, 0.1)
y_s_1 = np.sin(x_1)
y_s_0_5 = np.sin(x_0_5)
y_s_0_1 = np.sin(x_0_1)
y_c = np.cos(x_1)
plt.plot(x_1,y_s_1,"purple", label="sin(x) with stepsize 1")
plt.plot(x_0_5,y_s_0_5,"pink", label="sin(x) with stepsize 0.5")
plt.plot(x_0_1,y_s_0_1,"red", label="sin(x) with stepsize 0.1")
plt.plot(x_1,y_c,"green", label="cos(x)")
plt.title("A2.a) Sine and Cosine")
plt.xlabel("x")
plt.ylabel("y")
plt.legend()
plt.show()