s0 = vp1.points(pts, c='blue', r=3, legend='point cloud') vp1.show(s0, at=0) s1 = s0.clone(c='dg') # a dark green copy of s0 # project s1 points into a smooth surface of points # return a demo actor showing 30 regressions at random points mls1 = smoothMLS2D(s1, f=0.5, showNPlanes=30) # first pass vp1.show(mls1, at=1, legend='first pass') mls2 = smoothMLS2D(s1, f=0.3, showNPlanes=30) # second pass vp1.show(mls2, at=2, legend='second pass') mls3 = smoothMLS2D(s1, f=0.1) # third pass vp1.show(s1, at=3, legend='third pass', zoom=1.3) #################################### draw errors vp2 = Plotter(pos=(200,400), shape=(1,2), axes=4) variances = s1.info['variances'] vmin,vmax = np.min(variances), np.max(variances) print('min and max of variances:', vmin,vmax) vcols = [ colorMap(v, 'jet', vmin, vmax) for v in variances ] # scalars->colors a0= vp2.spheres(s1.coordinates(), c=vcols, r=0.03, legend='variance') a1= vp2.spheres(s1.coordinates(), c='red', r=variances, legend='variance') vp2.show(a0, at=0) vp2.show([a1, act], at=1, zoom=1.3, interactive=1)
# Example that shows how to draw very large number of # spheres (same for points, lines) with different colors # or different radius. Resolution (res) can be specified. # (vtk versions<8.0 might be slow) # from vtkplotter import Plotter from random import gauss N = 100000 vp = Plotter(N=2, axes=3, interactive=0) print('calculating..') cols = range(N) #color numbers pts = [(gauss(0, 1), gauss(0, 2), gauss(0, 1)) for i in cols] rads = [abs(pts[i][1]) / 10 for i in cols] # radius=0 for y=0 # all have same radius but different colors: s0 = vp.spheres(pts, c=cols, r=0.1, res=3) # res=resolution # all have same color (texture) but different radius along y: s1 = vp.spheres(pts, r=rads, res=10, texture='gold1') vp.show(s0, at=0) print('..rendering spheres:', N * 2) vp.show(s1, at=1, legend='N=' + str(N), interactive=1)