plt.rcParams[
'font.sans-serif'
]=[
'SimHei'
]
plt.rcParams[
'axes.unicode_minus'
] =
False
data1 = [
0.2515
,
0.3724
,
0.3336
,
0.0368
,
0.0057
]
labels = [
'中专'
,
'大专'
,
'本科'
,
'硕士'
,
'其他'
]
plt.pie(x=data1,labels=labels,autopct=
'%.1f%%'
)
plt.show()
data1 = [
0.2515
,
0.3724
,
0.3336
,
0.0368
,
0.0057
]
labels = [
'中专'
,
'大专'
,
'本科'
,
'硕士'
,
'其他'
]
explode = [
0
,
0.1
,
0
,
0
,
0
]
plt.axes(aspect=
'equal'
)
plt.pie(
x=data1,
explode=explode,
labels=labels,
autopct=
'%.1f%%'
,
pctdistance=
0.8
,
labeldistance=
1.1
,
textprops = {
'fontsize'
:
10
,
"color"
:
"black"
}
plt.title(
"失信用户的受教育水平分布"
)
plt.show()
data1 = [
0.2515
,
0.3724
,
0.3336
,
0.0368
,
0.0057
]
labels = [
'中专'
,
'大专'
,
'本科'
,
'硕士'
,
'其他'
]
data2 = {l:d
for
d,l
in
zip(data1,labels)}
print(data2)
data2 = pd.Series(data2)
data2.name =
''
plt.axes(aspect=
'equal'
)
data2.plot(
kind=
'pie'
,
autopct=
"%.1f%%"
,
title=
"失信用户的受教育水平分布"
,
explode=[
0
,
0.1
,
0
,
0
,
0
],
textprops = {
'fontsize'
:
10
,
'color'
:
"black"
}
plt.show()
饼图绘制结果
2. 绘制折线图
折线图1
折线图2
折线图3
更多内容请关注微信公众号