害,折腾了我好久
1. 直方图和概率密度图叠加
import matplotlib
.pyplot
as plt
import numpy
as np
import seaborn
as sns
lengths
= []
with open("D:/length_analysis.tsv","r") as f
:
for l
in f
:
if int(l
.split
('\t')[2])>80:
continue
lengths
.append
(int(l
.split
('\t')[2])//2)
plt
.style
.use
('seaborn')
plt
.grid
(linestyle
="-", alpha
=0.5,linewidth
=1.5)
bins
=[0,5,10,15,20,25,30,35,40]
sns
.distplot
(lengths
, bins
,hist
=True,kde
=True,color
='royalblue')
plt
.xticks
(range(0, 45)[::5] ,fontsize
=10)
plt
.tick_params
(labelsize
=13)
plt
.show
()
2. 折线图
import matplotlib
.pyplot
as plt
plt
.style
.use
('seaborn')
plt
.grid
(linestyle
="-", alpha
=0.5,linewidth
=1.5)
x
= [u
'<=5',u
'5<l<=10',u
'10<l<=15',u
'15<l<=20',u
'20<l<=25',u
'25<l<=30',u
'30<l<=35',u
'35<l']
k1
= [0.909090909, 0.853952395, 0.84803377, 0.834743006, 0.789830508, 0.773584906, 0.625, 0.285714286]
k2
= [0.909090909, 0.888627681, 0.872250611, 0.860767729, 0.850847458, 0.849056604, 0.583333333, 0.714285714]
k3
= [0.909090909, 0.889509257, 0.884692291, 0.869225764, 0.861016949, 0.849056604, 0.708333333, 0.571428571]
for i
in range(len(k1
)):
k1
[i
]*=100
k2
[i
]*=100
k3
[i
]*=100
plt
.plot
(x
,k3
,'s-',color
= 'red',label
="Bert + MS-SAN")
plt
.plot
(x
,k2
,'o-',color
= 'royalblue',label
="MS-SAN")
plt
.plot
(x
,k1
,'*-',color
= 'limegreen',label
="Bert-base")
plt
.tick_params
(labelsize
=12)
plt
.xlabel
("Avg_length(l)")
plt
.ylabel
("ACC(%)")
plt
.legend
(loc
= "best")
plt
.show
()
补充:
mark
'.' point marker
',' pixel marker
'o' circle marker
'v' triangle_down marker
'^' triangle_up marker
'<' triangle_left marker
'>' triangle_right marker
'1' tri_down marker
'2' tri_up marker
'3' tri_left marker
'4' tri_right marker
's' square marker
'p' pentagon marker
'*' star marker
'h' hexagon1 marker
'H' hexagon2 marker
'+' plus marker
'x' x marker
'D' diamond marker
'd' thin_diamond marker
'|' vline marker
'_' hline marker
2, color