How to use the mayavi.mlab.points3d function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MaterialsDiscovery / PyChemia / pychemia / visual / structure_plot.py View on Github external
def plot(self, figname=None, size=(300, 325), view=(30, 30)):

        fig = mlab.figure(size=size)
        figure = mlab.gcf()
        fig.scene.disable_render = True
        figure.scene.background = (0.0, 0.0, 0.0)
        mlab.view(0, 90, distance=0.2)
        assert (self.natom > 0)

        x = self.positions[:, 0]
        y = self.positions[:, 1]
        z = self.positions[:, 2]
        cr = covalent_radius(self.symbols)
        s = np.apply_along_axis(np.linalg.norm, 1, self.positions)

        mlab.points3d(x, y, z, s, scale_factor=1.0, resolution=8, opacity=1.0, colormap='Spectral', scale_mode='none')

        if self.is_crystal:
            frame, line1, line2, line3 = self.get_cell().get_path()

            mlab.plot3d(frame[:, 0], frame[:, 1], frame[:, 2], tube_radius=.02, color=(1, 1, 1))
            mlab.plot3d(line1[:, 0], line1[:, 1], line1[:, 2], tube_radius=.02, color=(1, 1, 1))
            mlab.plot3d(line2[:, 0], line2[:, 1], line2[:, 2], tube_radius=.02, color=(1, 1, 1))
            mlab.plot3d(line3[:, 0], line3[:, 1], line3[:, 2], tube_radius=.02, color=(1, 1, 1))
        else:
            for i in range(self.natom - 1):
                for j in range(i + 1, self.natom):
                    vector = self.positions[i] - self.positions[j]
                    mvector = np.linalg.norm(vector)
                    uvector = 1.0 / mvector * vector
                    if 2 * mvector < covalent_radius(self.symbols[i]) + covalent_radius(self.symbols[j]):
                        pair = np.concatenate(
github stanford-iprl-lab / sceneflownet / segNet / tf_libs / experiment.py View on Github external
gtyy = gtxyz[:,4] * s + gtxyz[:,1]
        gtzz = gtxyz[:,5] * s + gtxyz[:,2]
        gtxy = gtxyz[:,6] * s + gtxyz[:,0]
        gtyz = gtxyz[:,7] * s + gtxyz[:,1]
        gtzx = gtxyz[:,8] * s + gtxyz[:,2]
 
        ugtxyz = np.unique(gtxyz,axis=0)
        gtxxyyzz = np.vstack([gtxx,gtyy,gtzz]).T
        gtxxyyzz = np.unique(gtxxyyzz,axis=0)
        ugtxx= gtxxyyzz[:,0]
        ugtyy = gtxxyyzz[:,1]
        ugtzz = gtxxyyzz[:,2]
        center = self.predv['instance_center']
        r = self.predv['instance_boundary']

        mayalab.points3d(inputxyz[:,0],inputxyz[:,1],inputxyz[:,2],color=(0,1,0),mode='point')
        mayalab.points3d(predxyz[:,0] , predxyz[:,1] , predxyz[:,2], mode='point')
        mayalab.points3d(predxx , predyy , predzz, mode='point', color=(0,0,1))

        gt_id = np.unique(self.gtv['feat'][0][:,:,2])
        for inst_id in gt_id:
          if inst_id > 0:
            tmp_id = self.gtv['feat'][0][:,:,2] == inst_id
            print(tmp_id.shape)
            predxyz_ = self.predv['feat_masked'][0][tmp_id]
            gtxyz_ = self.gtv['feat'][0][tmp_id] 
            dfxyz_ = predxyz_ - gtxyz_            
            print(np.std(dfxyz_,axis=0))
        for jj in xrange(len(ugtxx)):
          #mayalab.points3d(center[jj:jj+1,0],center[jj:jj+1,1],center[jj:jj+1,2],color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=r[jj])
          mayalab.points3d(ugtxx, ugtyy, ugtzz,color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=0.01)
          mayalab.points3d(ugtxyz[:,0], ugtxyz[:,1], ugtxyz[:,2],color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=0.01)
github Lujano / PointCloudLM-Software / PointCloud / Codigo / 3DPlot_Fase1.py View on Github external
def viewer_pointcloud(pointcloud):
    mlab.figure(bgcolor=(1, 1, 1))
    mlab.points3d(pointcloud[:, 0], pointcloud[:, 1], pointcloud[:, 2], color=(0, 0, 0), mode='point')
    mlab.show()
    return
github Lujano / PointCloudLM-Software / Integracion / IntegracionComponentes.py View on Github external
def viewer_pointcloud1_vs_pointcloud2(pointcloud1, pointcloud2):
    sensor_range = 120.0
    mlab.figure(bgcolor=(1, 1, 1))
    mlab.points3d(pointcloud1[:, 0], pointcloud1[:, 1], pointcloud1[:, 2], color=(0, 0, 0), mode='point')
    mlab.points3d(pointcloud2[:, 0], pointcloud2[:, 1], pointcloud2[:, 2], color=(1, 0, 0), mode='point')
    mlab.show()
    return
github edraizen / molmimic / molmimic / visualize / mayavi_vieiwer.py View on Github external
def plot_volume(volume, binding_site=None):
    fig = mayavi.mlab.figure(bgcolor=(1,1,1), size=(500, 500))

    tx, ty, tz, _ = np.where(volume == 1)
    mayavi.mlab.points3d(tx, ty, tz, mode="cube", scale_factor=1, color=(0,1,0), opacity=1)

    if binding_site is not None:
        bx, by, bz, _ = np.where(binding_site == 1)
        mayavi.mlab.points3d(bx, by, bz, mode="cube", scale_factor=1, color=(0,0,1), opacity=1)

    wall_west((0,96,0,96,0,96))
    wall_south((0,96,0,96,0,96))
    wall_top((0,96,0,96,0,96))
github Lujano / PointCloudLM-Software / Integracion / 3DPlot_PointCloudLM.py View on Github external
def viewer_original_vs_ransac_pointcloud_vs_plane(ransac_pcl, original_pcl, plane_model):
    sensor_range = 120.0
    mlab.figure(bgcolor=(1, 1, 1))
    x, y = np.ogrid[-sensor_range+50:sensor_range+50:1, -sensor_range:sensor_range:1]
    mlab.points3d(original_pcl[:, 0], original_pcl[:, 1], original_pcl[:, 2], color=(0, 0, 0), mode='point')
    mlab.points3d(ransac_pcl[:, 0], ransac_pcl[:, 1], ransac_pcl[:, 2], color=(1, 0, 0), mode='point')
    mlab.surf(x, y, (-plane_model[3] - (plane_model[0]*x) - (plane_model[1]*y)) / plane_model[2],
              color=(0.8, 0.8, 1), opacity=0.3)
    mlab.show()
    return
github menpo / menpo / tosort / face.py View on Github external
def view_location_of_vertices(self, coords):
    self.view()
    s = mlab.points3d(coords[:,0], coords[:,1],
                      coords[:,2],
                      color=(1,1,1), mode='axes')
    mlab.show()
github fwilliams / deep-geometric-prior / reconstruct_single_patch.py View on Github external
def plot_correspondences(model, uv, x, pi):
    y = model(uv).detach().squeeze().cpu().numpy()

    from mayavi import mlab
    mlab.figure(bgcolor=(1, 1, 1))
    mlab.points3d(x[:, 0], x[:, 1], x[:, 2], color=(1, 0, 0), scale_factor=0.01)
    mlab.points3d(y[:, 0], y[:, 1], y[:, 2], color=(0, 1, 0), scale_factor=0.01)
    x = x[pi].detach().squeeze().cpu().numpy()

    for i in range(x.shape[0]):
        lx = [x[i, 0], y[i, 0]]
        ly = [x[i, 1], y[i, 1]]
        lz = [x[i, 2], y[i, 2]]

        mlab.plot3d(lx, ly, lz, color=(0.1, 0.1, 0.1), tube_radius=None)
    mlab.show()
github StructuralNeurobiologyLab / SyConn / syconn_deprecated / utils / illustration.py View on Github external
skel.removeNode(node)
    if hull_visualization is True:
        bools = get_box_coords(skel.hull_coords / 10., min_pos, max_pos,
                               ret_bool_array=True)
        hull_points = skel.hull_coords[bools] / 10.
        hull_normals = skel.hull_normals[bools]
        if save_vx_dir is not None:
            hull2text(hull_points, hull_normals, save_vx_dir +
                      skel.filename + 'hull.xyz')
            return
        # while len(hull_points) > 0.3e6:
            # hull_points = hull_points[::2]
            # print "Subsampling"
        if cmap is not None:
            skel.color = None
        mlab.points3d(hull_points[:, 0], hull_points[:, 1], hull_points[:, 2],
                      scale_factor=1.5, mode='sphere', color=skel.color,
                      opacity=op, colormap=cmap)
    else:
        add_anno_to_mayavi_window(skel, 1./10., 5, dataset_identifier='',
                                  show_outline=False)
github stanford-iprl-lab / sceneflownet / segNet / tf_libs / experiment.py View on Github external
mayalab.points3d(predxyz[:,0] , predxyz[:,1] , predxyz[:,2], mode='point')
        mayalab.points3d(predxx , predyy , predzz, mode='point', color=(0,0,1))

        gt_id = np.unique(self.gtv['feat'][0][:,:,2])
        for inst_id in gt_id:
          if inst_id > 0:
            tmp_id = self.gtv['feat'][0][:,:,2] == inst_id
            print(tmp_id.shape)
            predxyz_ = self.predv['feat_masked'][0][tmp_id]
            gtxyz_ = self.gtv['feat'][0][tmp_id] 
            dfxyz_ = predxyz_ - gtxyz_            
            print(np.std(dfxyz_,axis=0))
        for jj in xrange(len(ugtxx)):
          #mayalab.points3d(center[jj:jj+1,0],center[jj:jj+1,1],center[jj:jj+1,2],color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=r[jj])
          mayalab.points3d(ugtxx, ugtyy, ugtzz,color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=0.01)
          mayalab.points3d(ugtxyz[:,0], ugtxyz[:,1], ugtxyz[:,2],color=(1,0,0),mode='sphere',opacity=0.1,scale_mode='vector',scale_factor=0.01)
          mayalab.quiver3d(ugtxyz[:,0], ugtxyz[:,1], ugtxyz[:,2], ugtxx - ugtxyz[:,0], ugtyy - ugtxyz[:,1], ugtzz - ugtxyz[:,2], scale_mode='vector',scale_factor=0.9)
        
        mayalab.show() 
        #plt.figure(0)
        #plt.imshow(self.predv['mask_truncated'][0])
        #plt.figure(1)
        #plt.imshow(self.predv['mask_positive'][0])
        #plt.figure(2)
      save = True 
      if save:
        tmp_path = os.path.join(self.result_save_epoch_top_dir,str(self.instance_idv[i]))
        np.savez(os.path.join(tmp_path,'gt'),seg=self.gtv['feat'][i][:,:,2])
        np.savetxt(os.path.join(tmp_path,'pred.txt'),self.predv['final_score'],fmt='%.8f')
        for j in range(len(self.predv['final_instance'])):
          np.savez(os.path.join(tmp_path,'pred'+str(j)),seg=self.predv['final_instance'][j])