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)显示
<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)显示