-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotProblem.py
More file actions
36 lines (34 loc) · 1.08 KB
/
plotProblem.py
File metadata and controls
36 lines (34 loc) · 1.08 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
import numpy as np
import matplotlib.pyplot as plt
#画柱状图并包含百分比
#输入为 dtype数组!!!!!!!!!!!!!!
def plt_bar(datalist,namelist,numFlag,name):
x = list(range(datalist.__len__()))
total_width, n = 0.8, 2
width = total_width / n
# plt.bar(x, np.asarray(datalist, dtype=np.float), width=width,
# tick_label=namelist, fc='r')
for i in range(len(x)):
x[i] = x[i] + width
plt.bar(x, np.asarray(datalist, dtype=np.float) / sum(numFlag), width=width,
tick_label=namelist, fc='b')
plt.title(name)
plt.show()
def plot_bar(x,name):
xx = list(range(x.shape[0]))
width = 0.1
for i in range(len(xx)):
xx[i] = xx[i] + width
# plt.xlim((0,1))
plt.title(name)
plt.show()
def plt_line(coordList):
for coord in coordList:
x=np.linspace(coord[0][0],coord[1][0],50)
y=np.linspace(coord[0][1],coord[1][1],50)
plt.plot(x,y)
plt.grid()
plt.show()
pass
# if __name__ == "__main__":
# plt_line(list(np.array([[[0, 0],[1, 1]]],dtype=np.float) ))