0%

论文中画各种图

画折线图

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
import matplotlib.pyplot as plt
import numpy as np

#epoch,acc,loss,val_acc,val_loss
x_axis_data = list(range(0,24,2))
y_axis_data1 = [68.72,69.17,69.26,69.63,69.35,70.3,66.8,90,92,93,95,99]
y_axis_data2 = [52,71,73,66,74,82,71,90,91,93,94,99]
y_axis_data3 = [82,83,82,76,84,92,81,90,91,92,93,95]

#画图
plt.gca().set_facecolor('#f3f7ff')

plt.plot(x_axis_data, y_axis_data1, 'b*--', alpha=1, linewidth=1, label='acc')#'
plt.plot(x_axis_data, y_axis_data2, 'rs--', alpha=1, linewidth=1, label='acc')
plt.plot(x_axis_data, y_axis_data3, 'go--', alpha=1, linewidth=1, label='acc')
plt.xticks(x_axis_data)
# plt.xticks(y_axis_data1)

plt.legend(loc="best") #显示上面的label
plt.xlabel('Hours')
plt.ylabel('Coverage')


# plt.grid(color='gray', alpha=0.5, linestyle=':')
plt.grid(True, which='major', linestyle='-', color='gray', alpha=0.3)
plt.grid(True, which='minor', linestyle=':', color='gray', alpha=0.3)
plt.minorticks_on()

# plt.figure(figsize=(12, 6),dpi=300) # 设置dpi为300,可以根据需要调整
plt.savefig('fix2.png', dpi=300) #指定分辨率保存
plt.show()
plt.close()

画柱状图

1

画雷达图

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
import matplotlib.pyplot as plt
import numpy as np
def plot_radar_chart(labels, array, title):

plt.rcParams.update({'font.size': 25})
# 设置全局刻度字体大小
# plt.rcParams['xtick.labelsize'] = 25 # x轴刻度字体大小
plt.rcParams['ytick.labelsize'] = 25 # y轴刻度字体大小

fuzzer = ["LLM_atr1","LLM_atr2","LLM_atr3","human"]
fuzzer = ["LLM","Human"]
colors = ['r','b','r','b']
num_vars = len(labels)
len_val = len(array)

angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()

angles += angles[:1]

fig, ax = plt.subplots(figsize=(14, 12), subplot_kw=dict(polar=True))

# 设置背景颜色
ax.set_facecolor('#f3f7ff') # 这里设置为浅灰色,你可以根据需要修改颜色

for i in range(len_val):
values = []
values = array[i]
values += values[:1]

# print(angles)
# print(values)
ax.fill(angles, values, color=colors[i], alpha=0.1)
ax.plot(angles, values, linewidth=1, linestyle='solid', label=fuzzer[i])


ax.grid(linewidth=1, linestyle='--', alpha=0.5)


ax.spines['polar'].set_visible(False)

#设置y轴显示
# ax.set_yticklabels([0,1,2,3,4])


ax.set_xticks(angles[:-1])

ax.set_xticklabels(labels)


# 调整圆的间隔
# ax.set_rticks([0, 0.3, 0.6, 0.9, 1.2]) # 设置径向刻度的位置
ax.set_rlabel_position(15) # 设置径向刻度标签的位置


# plt.title(title)

# 添加图例loc='best',
plt.legend(loc = (0.9, 0.95))
# fig.legend(loc='best')

return ax

# # 打印所有可用的样式列表
# for i in plt.style.available:
#可读性
#DIV/0!
# values = [ [4.088888889, 3.458730159, 3.576190476],[3.771428682, 2.492063381, 3.657142857]]
# plot_radar_chart(['name', 'note', 'field'],values, '')

#语义
# [0.83521746,0.769798413,0.704907937,0.65028254,0.7487], [0.83521746,0.769798413,0.704907937,0.65028254,0.9366],
# values = [ [0.83521746,0.769798413,0.704907937,0.65028254,1],[0.684297279,0.639577778 ,0.584657143,0.505793651,1]]
# plot_radar_chart(['data model', 'state model','action', 'transfer', 'attribute'],values, '')

# values = [ [0.83521746,0.769798413,0.704907937,0.65028254,0.7487,4.088888889/5, 3.458730159/5, 3.576190476/5],
# [0.684297279,0.639577778 ,0.584657143,0.505793651,1,3.771428682/5, 2.492063381/5, 3.657142857/5]]
# plot_radar_chart(['data model', 'state model','action', 'transfer', 'attribute','name', 'note', 'field'],values, '')

# values = [ [0.83521746,0.769798413,0.704907937,0.65028254,0.9366,4.088888889/5, 3.458730159/5, 3.576190476/5],
# [0.684297279,0.639577778 ,0.584657143,0.505793651,1,3.771428682/5, 2.492063381/5, 3.657142857/5]]
# plot_radar_chart(['data model', 'state model','action', 'transfer', 'attribute','name', 'note', 'field'],values, '')

values = [ [0.83521746,0.769798413,0.704907937,0.65028254,1,4.088888889/5, 3.458730159/5, 3.576190476/5],
[0.684297279,0.639577778 ,0.584657143,0.505793651,1,3.771428682/5, 2.492063381/5, 3.657142857/5]]
plot_radar_chart(['DataModelNode', 'StateModelNode','Action', 'Transfer', 'Attribute','Name', 'Note', 'Field'],values, '')

plt.savefig('read.png', dpi=300) #指定分辨率保存
plt.show()
plt.close()
------------- Thank you for reading -------------

Title - Artist
0:00