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
37
38
39
40
41
42
43
44
45
46
47
| import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
#x와 y의 리스트 크기는 동일해야 함.
x=np.array([0,1,6,8])
y=np.array([0,3,8,10])
plt.plot(x,y)
plt.show()
plt.plot(y)
plt.show()
colors = np.array(["red","black","pink","purple"])
plt.sactter(x, y, c=colors)
plt.show()
plt.bar(x, y)
plt.show()
x=np.random.normal(170, 10, 250)
plt.hist(x)
plt.show()
x = np.arange(0, 3 * np.pi, 0.3)
y_sin = np.sin(x)
y_cos = np.cos(x)
# Plot the points using matplotlib
plt.plot(x, y_sin, 'o-', color='b')
plt.plot(x, y_cos)
plt.xlabel('x axis label')
plt.ylabel('y axis label')
plt.title('Sine and Cosine')
plt.legend(['Sine', 'Cosine'])
# Set up a subplot grid that has height 2 and width 1,
# and set the first such subplot as active, and make the first plot.
plt.subplot(2, 1, 1)
plt.plot(x, y_sin, 'o-', color='b')
plt.title('Sine')
# Set the second subplot as active, and make the second plot.
plt.subplot(2, 1, 2)
plt.plot(x, y_cos)
plt.title('Cosine')
# Show the figure.
plt.suptitle("Sine and Cosine")
plt.show()
|