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 33 34 35 36
| import matplotlib.pyplot as plt import numpy as np
x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x)) plt.show()
x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x), x, np.sin(2 * x)) plt.show()
x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x), 'r-o', x, np.cos(x), 'g--') plt.show()
x = np.linspace(0, 2 * np.pi, 50) plt.subplot(2, 1, 1) plt.plot(x, np.sin(x), 'r') plt.subplot(2, 1, 2) plt.plot(x, np.cos(x), 'g') plt.show()
x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x), 'r-x', label='Sin(x)') plt.plot(x, np.cos(x), 'g-^', label='Cos(x)') plt.legend() plt.xlabel('Rads') plt.ylabel('Amplitude') plt.title('Sin and Cos Waves') plt.show()
|