最终画图大王

#仅画图
import numpy as np
import matplotlib.pyplot as plt
#matplotlib inline
from matplotlib import image
from matplotlib import pyplot as plt
#单纯画图
def loadDataSet(fileName):  
    dataMat = []              # 初始化一个空列表,文件的最后一个字段是类别标签
    fr = open(fileName)       # 读取文件
    for line in fr.readlines():   # 循环遍历文件所有行
        curLine = line.strip().split(' ')   # 切割每一行的数据
        fltLine = list(map(float, curLine))  # 映射所有的元素为 float(浮点数)类型
        dataMat.append(fltLine)   # 将数据追加到dataMat
    return dataMat       # 返回dataMat

datMat1 = np.mat(loadDataSet('./after_label_training_center_expand.txt'))#1轮震中

datMat2 = np.mat(loadDataSet('./two_train_xin.txt'))#2轮震中
datMat3 = np.mat(loadDataSet('./nolabel.txt'))#伪震中
data = image.imread('地图.png')
plt.figure(1)
plt.imshow(data,extent=(0, data.shape[1], 0, data.shape[0]))

x1 = list((datMat1)[:,0])
y1 = list((datMat1)[:,1])
x2 = list((datMat2)[:,0])
y2 = list((datMat2)[:,1])

nolabel_x = []
nolabel_y = []
yeslabel_x = []
yeslabel_y = []
x = list((datMat3)[:,0])
for i in range(0,len(x)-10,1):
    nolabel_x.append(x[i])
print(len(nolabel_x))
for i in range(len(x)-10,len(x),1):
    yeslabel_x.append(x[i])
print(yeslabel_x)
y = list((datMat3)[:,1])
for i in range(0,len(y)-10,1):
    nolabel_y.append(y[i])
for i in range(len(y)-10,len(y),1):
    yeslabel_y.append(y[i])
#画图形状可参考http://t.csdn.cn/wDfGc

plt.scatter(nolabel_x, nolabel_y,marker = 'x',s=10)
plt.scatter(yeslabel_x, yeslabel_y,marker = 'P',s=10)

plt.scatter(x1, y1,marker = '*',s=50,c='blue')
plt.scatter(x2, y2,marker = 'p',s=100,c='red')


plt.show()

最终画图大王_第1张图片

 

你可能感兴趣的:(python,开发语言)