-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatplotlib.py
More file actions
152 lines (103 loc) · 3.06 KB
/
matplotlib.py
File metadata and controls
152 lines (103 loc) · 3.06 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# -*- coding: utf-8 -*-
"""Matplotlib.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1nR9BVC1ru4hiOtEvk9LhCcpFXgNNPS8Q
#matplotlib
**pyplot**
"""
import matplotlib.pyplot as plt
import numpy as np
xpoints = np.array([1, 2, 6, 8])
ypoints = np.array([0, 250, 300, 200])
ypoints2 = np.array([50, 200, 100, 100])
ypoints3 = np.array([100, 150, 170, 100])
plt.plot(xpoints, ypoints)
plt.plot(xpoints, ypoints2,'o')
plt.plot(xpoints, ypoints3,'-.')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10, 5, 7])
plt.plot(ypoints)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
plt.plot(ypoints,marker='o',color='#555555',ls='--',linewidth = '4',ms=12,mfc='Aquamarine',mec='r')
plt.show()
"""https://www.w3schools.com/python/matplotlib_markers.asp"""
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([3, 8, 1, 10])
font1 = {'family':'serif','color':'blue','size':20}
plt.plot(ypoints,marker='o',color='b',ls='--',linewidth = '4',ms=12,mfc='Aquamarine',mec='r')
plt.xlabel("my x")
plt.ylabel("my y")
plt.title("My Plot",fontdict=font1,loc='left')
plt.grid(axis='y',color='r',ls='--',linewidth=.5)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
#plot 1:
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 3, 1)
plt.plot(x,y)
plt.title("t1")
#plot 2:
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 3, 5)
plt.plot(x,y)
plt.title("t2")
plt.subplot(2, 3, 3)
plt.plot(x,y)
plt.title("t3")
plt.suptitle("Title")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
plt.scatter(x, y,color='pink')
x = np.array([2,2,8,1,15,8,12,9,7,3,11,4,7,14,12])
y = np.array([100,105,84,105,90,99,90,95,94,100,79,112,91,80,85])
plt.scatter(x, y,color="#777777")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.array([4,2,6,8])
y = np.array([34,33,65,10])
cols = np.array(['blue','brown','pink','red'])
plt.scatter(x,y,c=cols)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.array([4,2,6,8])
y = np.array([34,33,65,10])
z = np.array([3,35,1000,53])
plt.scatter(x,y,c=z,cmap='Pastel1',s=z)
plt.show()
"""https://www.w3schools.com/python/matplotlib_scatter.asp
"""
import matplotlib.pyplot as plt
import numpy as np
x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
sizes = np.array([20,50,100,200,500,1000,60,90,10,300,600,800,75])
plt.scatter(x, y, s=sizes, alpha=0.5)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x = np.array(["A", "B", "C", "D"])
y = np.array([3, 8, 1, 10])
plt.barh(x,y,color='red')
plt.show()
import matplotlib.pyplot as plt
import numpy as np
y = np.array([35, 25, 205, 15])
st = np.array(['a','b','c','d'])
plt.pie(y,labels=st,startangle=50,explode=np.repeat(.2,4))
plt.legend(["A","B","C","D"],title="Legend title")
plt.show()