KNN(三) 用Matplolib分析数据

1预备知识

安装Matplotlib库的过程不提,百度后都一一解决

2资料


3.代码详解

<pre name="code" class="python">#coding:gbk
'''
Created on 2015年4月29日

@author: dell
'''
import matplotlib
import matplotlib.pyplot as plt #matplotlib.pyplot是一个快速绘图类
fig  = plt.figure() #Creates a new figure.
fig.add_subplot(110.9)#这个函数的三个参数第一个是x轴,第二个是y轴,第三个是比例,0《num《1 如果x=2,y=1说明x轴要比y轴长一倍
#ax.scatter(datingDataMat[:,1],datingDataMat[:,2]) 注释掉的原因是datingMat是数据,重点在于scatter函数,api给出的解释 Make a scatter plot of x vs y, where x and y are sequence like objects of the same lengths.书中给出的解释是scatter函数支持个性化标记散点图的点

plt.show() #显示这个figure 
print(help(plt.figure()))
# ax.scatter(x,y,15.0*array(datingLabels),15.0*array(datingLabels))
#sactter类似于载入x轴和y轴要表示的数据,ax.scatter(datingDataMat[:,1],datingDataMat[:,2])和ax.scatter(x,y,15.0*array(datingLabels),15.0*array(datingLabels))可以很明显的指导,x轴和y轴相同,然后按15.0*array(datingLabels)显示


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值