from sklearn import datasets
import math
import matplotlib.pyplot as plt #导入绘图库
house=datasets.load_boston()
x= house.data
y= house.target
nums=len(house.feature_names) #计数有多少个特征
colunms=3 #一行显示三个图,即三列
rows=math.ceil(nums/colunms) #行数等于特征个数除以列数并向上取整
plt.figure(figsize=(10,12)) #设置图片大小
for i in range(nums):
plt.subplot(rows, colunms,i+1)
plt.plot(x[:,i],y, "b+")
plt.title(house.feature_names[i]) #给每个图表添加标题
plt.subplots_adjust(hspace=0.8) #再度调整图表高度
plt.savefig("filename.png") #保存图表
plt.show()
12-07
4386
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-19
1176
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)