-
Notifications
You must be signed in to change notification settings - Fork 1
/
Matplotlib.txt
69 lines (44 loc) · 871 Bytes
/
Matplotlib.txt
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Line Plot
import matplotlib.pyplot as plt
# Data
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
# Create the plot
plt.plot(x, y)
# Show the plot
plt.show()
Scatter Plot
import matplotlib.pyplot as plt
# Data
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
# Create the plot
plt.scatter(x, y)
# Show the plot
plt.show()
Bar Plot
import matplotlib.pyplot as plt
# Data
x = ['Cat', 'Dog', 'Fish']
y = [10, 20, 15]
# Create the plot
plt.bar(x, y)
# Show the plot
plt.show()
Histogram
import matplotlib.pyplot as plt
# Data
x = [10, 20, 25, 30, 35, 40, 45, 50]
# Create the plot
plt.hist(x, bins=4)
# Show the plot
plt.show()
Pie Chart
import matplotlib.pyplot as plt
# Data
labels = ['Cat', 'Dog', 'Fish']
sizes = [10, 20, 15]
# Create the plot
plt.pie(sizes, labels=labels)
# Show the plot
plt.show()