1. 数据样本
,valid_rate,homework_rate,inter_rate,playback_rate,zhujiang_good_comment5_rate,fudao_good_comment5_rate,if_purchased,cust,cust_per
0,0.629536534447,0.216511482255,0.70731691023,-8.04911692853e-16,0.948508768267,0.982603131524,0.0751565762004,479,0.188582677165
1,0.858778725237,0.93392997416,0.925245478036,2.16493489802e-15,0.953323341947,0.984113953488,0.118863049096,1161,0.457086614173
2,0.827973648649,0.732318581081,0.883406081081,0.0844594594595,0.332026351351,0.0472962837838,0.0777027027027,296,0.116535433071
3,0.728237267081,0.823232608696,0.788694409938,1.0,0.938818944099,0.922187888199,0.111801242236,322,0.126771653543
4,0.260557092199,0.157164539007,0.329861347518,0.063829787234,0.436144680851,0.00709219858156,0.0567375886525,282,0.111023622047
2. format 把cust_per打印成百分值输出
iloc取指定位置的元素
r = pd.read_csv(r_file, header=0) # print r['cust_per'].head(1) # 不行,会同时输出列名或者序号 print format(r.iloc[0,-1], '.0%') # iloc取第0行最后1列位置的元素
3. 把打印出来的百分值拼接起来
fig = plt.figure() ax = fig.add_subplot(111, polar=True)# polar参数!! ax.plot(angles, data0, 'bo-', linewidth=1,label=u'1类%.2f%%' % (r.iloc[0,-1]*100) )# 画线 ax.plot(angles, data1, 'go-', linewidth=1,label=u'2类%.2f%%' % (r.iloc[1,-1]*100))# 画线 ax.plot(angles, data2, 'co-', linewidth=1,label=u'3类%.2f%%' % (r.iloc[2,-1]*100))# 画线 ax.plot(angles, data3, 'ro-', linewidth=1,label=u'4类%.2f%%' % (r.iloc[3,-1]*100))# 画线 ax.plot(angles, data4, 'mo-', linewidth=1,label=u'5类%.2f%%' % (r.iloc[4,-1]*100))# 画线
4. 调整图例和图的位置
#利用bbox_to_anchor 来调整图例 box = ax.get_position() ax.set_position([box.x0, box.y0, box.width*0.8, box.height]) ax.legend(loc='upper right', bbox_to_anchor=(0.2, 1.12),ncol=1)
5. 保存 matlibplot.plot 画出来的图
plt.savefig('D:/a/b.png')
每天进步一点点