-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path三维散点图.py
47 lines (46 loc) · 1.17 KB
/
三维散点图.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 16 12:57:05 2017
@author: Lenovo-Y430p
"""
#散点图
from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
from numpy import *
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
xcord0 = []; ycord0 = [];zcord0=[];gcord0=[]
xcord1=[];ycord1=[];zcord1=[];gcord1=[]
fr = open('E:\下载\机器学习实战及配套代码\machinelearninginaction\Ch06\EXTRAS\shuju1.txt')#this file was generated by 2normalGen.py
for line in fr.readlines():
lineSplit = line.strip().split('\t')
xPt = float(lineSplit[0])
yPt = float(lineSplit[1])
zpt=float(lineSplit[2])
gpt=float(lineSplit[3])
label = int(lineSplit[4])
if (label == 1):
xcord0.append(xPt)
ycord0.append(yPt)
zcord0.append(zpt)
gcord0.append(gpt)
else:
xcord1.append(xPt)
ycord1.append(yPt)
zcord1.append(zpt)
gcord1.append(gpt)
fr.close()
fig = plt.figure()
ax = fig.add_subplot(111)
x = xcord0
y = ycord0
z=zcord0
d=gcord0
x1= xcord1
y1=ycord1
z1=zcord1
ax.scatter3(x,y,z,'o',d,'filled')
ax.view(0,90)
ax.colorbar
plt.show()