Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jerrrrry
easystart_v0.2
Commits
f9b80654
Commit
f9b80654
authored
Jul 23, 2025
by
jerrrrry
Browse files
Replace plot.py
parent
9d0fa1e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
39 deletions
+42
-39
plot.py
plot.py
+42
-39
No files found.
plot.py
View file @
f9b80654
...
...
@@ -31,63 +31,66 @@ def plot_summary(file_path, output_prefix):
summary
[
sheet
]
=
extract_values
(
df
)
except
Exception
:
continue
if
not
summary
:
print
(
"❌ 无数据可绘图"
)
return
labels
=
[
"Total_throughput"
,
"generate_throughput"
,
"singel_road_generate_throughput"
,
"generate_throughput_without_ttft"
]
colors
=
[
'#2E5984'
,
'#FF8C42'
,
'#4CB944'
,
'#8C2F39'
]
labels
=
[
"Total_throughput"
,
"generate_throughput"
,
"singel_road_generate_throughput"
,
"generate_throughput_without_ttft"
]
# 大师级配色(Material 2024)
colors
=
[
'#005F73'
,
'#0A9396'
,
'#94D2BD'
,
'#E9D8A6'
]
models
=
list
(
summary
.
keys
())
x
=
range
(
len
(
models
))
bar_width
=
0.18
plt
.
figure
(
figsize
=
(
max
(
len
(
models
)
*
1.2
,
12
),
8
))
# 绘制柱状图
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
max
(
len
(
models
)
*
1.1
,
14
),
8
))
fig
.
patch
.
set_facecolor
(
'#F8F9FA'
)
ax
.
set_facecolor
(
'#FFFFFF'
)
for
i
,
lab
in
enumerate
(
labels
):
vals
=
[
summary
[
m
][
lab
]
for
m
in
models
]
offset
=
(
i
-
1.5
)
*
bar_width
bars
=
plt
.
bar
([
p
+
offset
for
p
in
x
],
vals
,
width
=
bar_width
,
label
=
lab
,
color
=
colors
[
i
])
# 添加带引导线的标注
bars
=
ax
.
bar
([
p
+
offset
for
p
in
x
],
vals
,
width
=
bar_width
,
label
=
lab
.
replace
(
'_'
,
' '
).
title
(),
color
=
colors
[
i
])
# 保持倾斜 60° + 虚线指引
for
bar
,
v
in
zip
(
bars
,
vals
):
height
=
bar
.
get_height
()
# 引导线起点(柱顶中心)
line_start
=
(
bar
.
get_x
()
+
bar
.
get_width
()
/
2
,
height
)
# 文本位置(柱顶上方5%处)
text_pos
=
(
line_start
[
0
],
height
+
max
(
vals
)
*
0.05
)
# 绘制引导线
plt
.
plot
([
line_start
[
0
],
text_pos
[
0
]],
[
line_start
[
1
],
text_pos
[
1
]],
color
=
'gray'
,
linestyle
=
'--'
,
linewidth
=
0.8
,
alpha
=
0.7
)
# 添加带背景框的文本
plt
.
text
(
text_pos
[
0
],
text_pos
[
1
],
f
"
{
v
:.
1
f
}
%"
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
6
,
rotation
=
60
,
bbox
=
dict
(
facecolor
=
'white'
,
edgecolor
=
'gray'
,
boxstyle
=
'round,pad=0.2'
))
# 虚线起点(柱顶中心)
line_start
=
(
bar
.
get_x
()
+
bar
.
get_width
()
/
2
,
height
)
# 文本终点(再向上 5%)
text_pos
=
(
line_start
[
0
],
height
+
max
(
vals
)
*
0.05
)
# 画虚线
ax
.
plot
([
line_start
[
0
],
text_pos
[
0
]],
[
line_start
[
1
],
text_pos
[
1
]],
color
=
'#555555'
,
linestyle
=
'--'
,
linewidth
=
0.8
,
alpha
=
0.7
)
# 倾斜 60° 文字
ax
.
text
(
text_pos
[
0
],
text_pos
[
1
],
f
"
{
v
:.
1
f
}
%"
,
ha
=
'center'
,
va
=
'bottom'
,
fontsize
=
7
,
rotation
=
60
,
color
=
'#000000'
,
weight
=
'bold'
)
plt
.
xticks
(
x
,
models
,
rotation
=
30
,
ha
=
'right'
,
fontsize
=
9
)
plt
.
ylabel
(
"Percentage"
,
fontsize
=
10
)
plt
.
title
(
"Throughput Comparison"
,
fontsize
=
12
,
pad
=
20
)
# 调整图例
plt
.
legend
(
bbox_to_anchor
=
(
1.02
,
1
),
loc
=
'upper left'
,
fontsize
=
9
,
frameon
=
False
)
plt
.
subplots_adjust
(
right
=
0.8
,
bottom
=
0.15
)
# 轴 & 网格
ax
.
set_xticks
(
x
)
ax
.
set_xticklabels
(
models
,
rotation
=
25
,
ha
=
'right'
,
fontsize
=
10
,
weight
=
'bold'
)
ax
.
set_ylabel
(
"Percentage"
,
fontsize
=
12
,
weight
=
'bold'
)
ax
.
set_title
(
"Throughput Comparison"
,
fontsize
=
16
,
weight
=
'bold'
,
pad
=
20
)
ax
.
grid
(
axis
=
'y'
,
linestyle
=
'-'
,
linewidth
=
0.3
,
alpha
=
0.3
,
color
=
'#DEE2E6'
)
ax
.
legend
(
frameon
=
False
,
loc
=
'upper left'
,
bbox_to_anchor
=
(
1.02
,
1
),
fontsize
=
9
)
plt
.
subplots_adjust
(
left
=
0.05
,
right
=
0.85
,
bottom
=
0.12
,
top
=
0.92
)
for
ext
in
[
'png'
,
'pdf'
]:
plt
.
savefig
(
f
"
{
output_prefix
}
.
{
ext
}
"
,
dpi
=
300
if
ext
==
'png'
else
None
,
bbox_inches
=
'tight'
)
plt
.
savefig
(
f
"
{
output_prefix
}
.
{
ext
}
"
,
dpi
=
300
if
ext
==
'png'
else
None
,
bbox_inches
=
'tight'
)
print
(
f
"✅ 已保存:
{
output_prefix
}
.png / .pdf"
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"xlsx_path"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment