mayavi points3d 渲染不正确
mayavi points3d renering incorectly
我有这样的代码:
import mayavi.mlab as mlab
import numpy as np
import random
#white blackground
mlab.figure(fgcolor=(0., 0., 0.), bgcolor=(1, 1, 1))
x1 = y1 = z1 = size1 = []
# number of points
number = 21
for i in range(1,number):
x1.append(random.randint(-10,11))
y1.append(random.randint(-10,11))
z1.append(random.randint(-10,11))
size1.append(i)
#create spheres
mlab.points3d(x1, y1, z1, size1, resolution=30)
#render
mlab.show()
结果呈现的点数多于 20:
我做错了什么?为什么球体不在随机位置和球体数量?
当 number == 2
时,渲染为 3 个球体:
好的,我知道了!
第一个错误是:
x1 = y1 = z1 = size1 = []
应该是:
x1 = []
y1 = []
z1 = []
size1 = []
并且最好在mlab.points3d
中加上scale_factor=1
我有这样的代码:
import mayavi.mlab as mlab
import numpy as np
import random
#white blackground
mlab.figure(fgcolor=(0., 0., 0.), bgcolor=(1, 1, 1))
x1 = y1 = z1 = size1 = []
# number of points
number = 21
for i in range(1,number):
x1.append(random.randint(-10,11))
y1.append(random.randint(-10,11))
z1.append(random.randint(-10,11))
size1.append(i)
#create spheres
mlab.points3d(x1, y1, z1, size1, resolution=30)
#render
mlab.show()
结果呈现的点数多于 20:
我做错了什么?为什么球体不在随机位置和球体数量?
当 number == 2
时,渲染为 3 个球体:
好的,我知道了! 第一个错误是:
x1 = y1 = z1 = size1 = []
应该是:
x1 = []
y1 = []
z1 = []
size1 = []
并且最好在mlab.points3d
scale_factor=1