-
Notifications
You must be signed in to change notification settings - Fork 89
/
Basic_Matplotlibgraph
85 lines (77 loc) · 1.92 KB
/
Basic_Matplotlibgraph
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Basic Python Graphs
from matplotlib import pyplot as plt
#plotting
plt.plot([1,2,3],[4,5,1])
#showing
plt.show()
#with label
from matplotlib import pyplot as plt
x=[5,8,10]
y=[12,16,6]
plt.plot(x,y)
plt.title('info')
plt.ylabel('Yaxis')
plt.xlabel('Xaxis')
plt.show()
#basic graphs with labels and color
from matplotlib import pyplot as plt
from matplotlib import style
style.use("ggplot")
x=[5,8,10]
y=[12,16,6]
x2=[6,9,11]
y2=[6,15,7]
plt.plot(x,y,'g',label='line one',linewidth=5)
plt.plot(x2,y2,'c',label='line two',linewidth=5)
plt.title('Epic info')
plt.ylabel('Yaxis')
plt.xlabel('Xaxis')
plt.legend()
plt.grid(True,color='k')
plt.show()
#bar graph
import matplotlib.pyplot as plt
plt.bar([1,3,5,7,9],[5,2,7,8,2] ,label="Example one")
plt.bar([2,4,6,8,10],[8,6,2,5,6], label="tow",color='g')
plt.legend()
plt.xlabel('bar height')
plt.ylabel('bar number')
plt.title('my plot')
plt.show()
#histograph
import matplotlib.pyplot as plt
population_ages = [22,34,45,65,67,78,99,100,22.13,54]
bins = [0,10,20,30,40,50,60,70,80,90,100,110,120,130]
plt.hist(population_ages,bins,histtype='bar',rwidth=0.8)
plt.xlabel('X')
plt.ylabel('Y')
plt.title=('Histogram')
plt.legend()
plt.show()
#scatter graph
import matplotlib.pyplot as plt
x = [1,2,3,4,5,6,7,8]
y = [5,2,4,6,7,8,2,9]
plt.scatter(x,y,label = 'skitscat', color = 'k')
plt.xlabel('X')
plt.ylabel('Y')
plt.title=('Scatter')
plt.legend()
plt.show()
#Area graph
import matplotlib.pyplot as plt
days = [1,2,3,4,5]
sleeping = [1,2,3,4,5]
eating =[5,6,7,8,9]
working = [4,7,8,9,0]
playing = [3,4,5,6,7]
plt.plot([],[],color = 'm' , label = 'sleeeping', linewidth = 5)
plt.plot([],[],color = 'c' , label = 'eating', linewidth = 5)
plt.plot([],[],color = 'r' , label = 'working', linewidth = 5)
plt.plot([],[],color = 'k' , label = 'playing', linewidth = 5)
plt.stackplot(days,eating,sleeping,playing,colors=['m','c','r','k'])
plt.xlabel('X')
plt.ylabel('Y')
plt.title=('Area Plot')
plt.legend()
plt.show()