-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow3d.py
50 lines (39 loc) · 1.46 KB
/
show3d.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
48
49
50
# -*- coding: utf-8 -*-
"""
Created on Wed May 22 11:17:17 2019
@author: Administrator
"""
import matplotlib.pyplot as plt
import math
from mpl_toolkits.mplot3d import Axes3D
def show_scatter3d(x, y, z, c=None):
fig = plt.figure()
for i in range(c.size(0)):
sqsz = round(math.sqrt(c.size(0)))
ax = fig.add_subplot(sqsz, (c.size(0) + sqsz - 1) / sqsz, i + 1, projection='3d')
ax.axis('equal')
ax.axis('off')
ax.view_init(90, -90)
ax.scatter(x, y, z, s=1, c=c[i, :], marker='.')
plt.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0, wspace=0)
plt.show()
def show_tripcolor(x, y, z, c=None):
fig = plt.figure()
for i in range(c.size(0)):
sqsz = round(math.sqrt(c.size(0)))
ax = fig.add_subplot(sqsz, (c.size(0) + sqsz - 1) / sqsz, i + 1)
ax.axis('equal')
ax.axis('off')
ax.tripcolor(x, y, c[i, :], shading='gouraud')
plt.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0, wspace=0)
plt.show()
def show_scatter(x, y, z, c=None):
fig = plt.figure()
for i in range(c.size(0)):
sqsz = round(math.sqrt(c.size(0)))
ax = fig.add_subplot(sqsz, (c.size(0) + sqsz - 1) / sqsz, i + 1)
ax.axis('equal')
ax.axis('off')
ax.scatter(x, y, 0.1, c[i, :])
plt.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0, wspace=0)
plt.show()