-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_graph.py
More file actions
51 lines (30 loc) · 1.02 KB
/
plot_graph.py
File metadata and controls
51 lines (30 loc) · 1.02 KB
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
48
49
50
import matplotlib.pyplot as plt
import scipy.io
import numpy as np
#from scipy.stats import norm
import random
from datetime import datetime
from numpy.linalg import det, norm
from mpl_toolkits import mplot3d
import sys
MAT_FILE = sys.argv[1]
LABEL_FILE = sys.argv[2]
data_mat = scipy.io.loadmat(MAT_FILE)#'Data.mat')
test = np.array(data_mat['X'])
# load numpy array from npz file
from numpy import load
# load dict of arrays
dict_data = load(LABEL_FILE)#'classification.npz')
# extract the first array
classification = dict_data['arr_0']
# print the array
print(classification)
random.seed(datetime.now())
colors = [(random.random(), random.random(), random.random()) for i in range(0,max(classification)+1)]#['red','blue','green','yellow','black','white',]
plt_colors = [colors[i] for i in classification]
fig = plt.figure()
#ax = fig.add_subplot(111,projection='3d')
ax = plt.axes(projection='3d')
ax.scatter3D(test[0,:],test[1,:],test[2,:],c=plt_colors)
#ax.scatter(test[0,:],test[1,:],test[2,:],c=plt_colors)
plt.show()