當前位置: 首頁>>代碼示例>>Python>>正文


Python art3d.Poly3DCollection方法代碼示例

本文整理匯總了Python中mpl_toolkits.mplot3d.art3d.Poly3DCollection方法的典型用法代碼示例。如果您正苦於以下問題:Python art3d.Poly3DCollection方法的具體用法?Python art3d.Poly3DCollection怎麽用?Python art3d.Poly3DCollection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mpl_toolkits.mplot3d.art3d的用法示例。


在下文中一共展示了art3d.Poly3DCollection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_collection

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def _get_collection(surface_type, surfaces, opacity, facecolor, edgecolors="black"):
    """Make collections from a list of EnergyPlus surfaces."""
    if surface_type == "shading":
        coords = [getcoords(s) for s in surfaces if not hasattr(s, "Surface_Type")]
    else:
        coords = [
            getcoords(s)
            for s in surfaces
            if hasattr(s, "Surface_Type")
            and s.Surface_Type.lower() == surface_type.lower()
        ]
    trimmed_coords = [c for c in coords if c]  # dump any empty surfaces
    collection = Poly3DCollection(
        trimmed_coords, alpha=opacity, facecolor=facecolor, edgecolors=edgecolors
    )
    return collection 
開發者ID:jamiebull1,項目名稱:geomeppy,代碼行數:18,代碼來源:view_geometry.py

示例2: display_hand

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def display_hand(hand_info, mano_faces=None, ax=None, alpha=0.2, batch_idx=0, show=True):
    """
    Displays hand batch_idx in batch of hand_info, hand_info as returned by
    generate_random_hand
    """
    if ax is None:
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')
    verts, joints = hand_info['verts'][batch_idx], hand_info['joints'][
        batch_idx]
    if mano_faces is None:
        ax.scatter(verts[:, 0], verts[:, 1], verts[:, 2], alpha=0.1)
    else:
        mesh = Poly3DCollection(verts[mano_faces], alpha=alpha)
        face_color = (141 / 255, 184 / 255, 226 / 255)
        edge_color = (50 / 255, 50 / 255, 50 / 255)
        mesh.set_edgecolor(edge_color)
        mesh.set_facecolor(face_color)
        ax.add_collection3d(mesh)
    ax.scatter(joints[:, 0], joints[:, 1], joints[:, 2], color='r')
    cam_equal_aspect_3d(ax, verts.numpy())
    if show:
        plt.show() 
開發者ID:hassony2,項目名稱:manopth,代碼行數:25,代碼來源:demo.py

示例3: _init_axis_3d

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def _init_axis_3d(axis, info, view=None):
    axis.set_xlabel(info['labels'][0])
    axis.set_ylabel(info['labels'][1])
    axis.set_zlabel(info['labels'][2])
    if 'xlim' in info and info['xlim'] is not None:
        axis.set_xlim(info['xlim'][0], info['xlim'][1])
    if 'ylim' in info and info['ylim'] is not None:
        axis.set_ylim(info['ylim'][0], info['ylim'][1])
    if 'zlim' in info and info['zlim'] is not None:
        axis.set_zlim(info['zlim'][0], info['zlim'][1])
    if view is not None:
        elevation, azimuth = view
        axis.view_init(elev=elevation, azim=azimuth)
    if 'lines' in info:
        for line in info['lines']:
            axis.plot([], [], **line)[0]
    if 'surfaces' in info:
        for surf in info['surfaces']:
            col = Poly3DCollection([], **surf)
            axis.add_collection3d(col) 
開發者ID:meco-group,項目名稱:omg-tools,代碼行數:22,代碼來源:plotlayer.py

示例4: plot_bbox

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_bbox(ax, bbox):
    # plot vertices
    ax.scatter(bbox[:, 0], bbox[:, 1], bbox[:, 2], c='k')

    # list of sides' polygons of figure
    verts = [[bbox[0], bbox[1], bbox[2], bbox[3]],
             [bbox[4], bbox[5], bbox[6], bbox[7]],
             [bbox[0], bbox[1], bbox[5], bbox[4]],
             [bbox[2], bbox[3], bbox[7], bbox[6]],
             [bbox[1], bbox[2], bbox[6], bbox[5]],
             [bbox[4], bbox[7], bbox[3], bbox[0]],
             [bbox[2], bbox[3], bbox[7], bbox[6]]]

    # plot sides
    bbox = Poly3DCollection(verts, linewidths=1, edgecolors='r', alpha=.1)
    bbox.set_facecolor('cyan')
    ax.add_collection3d(bbox) 
開發者ID:wentaoyuan,項目名稱:pcn,代碼行數:19,代碼來源:process_kitti_raw.py

示例5: plot_3d

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_3d(image, threshold=-300):
    # Position the scan upright, 
    # so the head of the patient would be at the top facing the camera
    p = image.transpose(2,1,0)

    #p = image
    
    verts, faces = measure.marching_cubes(p, threshold)

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111, projection='3d')

    # Fancy indexing: `verts[faces]` to generate a collection of triangles
    mesh = Poly3DCollection(verts[faces], alpha=0.70)
    face_color = [0.45, 0.45, 0.75]
    mesh.set_facecolor(face_color)
    ax.add_collection3d(mesh)

    ax.set_xlim(0, p.shape[0])
    ax.set_ylim(0, p.shape[1])
    ax.set_zlim(0, p.shape[2])

    plt.show() 
開發者ID:mattmacy,項目名稱:torchbiomed,代碼行數:25,代碼來源:utils.py

示例6: plot_3d

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_3d(image, threshold=-300):
    # Position the scan upright,
    # so the head of the patient would be at the top facing the camera
    p = image.transpose(2, 1, 0)
    p = p[:, :, ::-1]

    verts, faces = measure.marching_cubes_classic(p, threshold)

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111, projection='3d')

    # Fancy indexing: `verts[faces]` to generate a collection of triangles
    mesh = Poly3DCollection(verts[faces], alpha=0.70)
    face_color = [0.45, 0.45, 0.8]
    mesh.set_facecolor(face_color)
    ax.add_collection3d(mesh)

    ax.set_xlim(0, p.shape[0])
    ax.set_ylim(0, p.shape[1])
    ax.set_zlim(0, p.shape[2])

    plt.show()


# plot_3d(pix_resampled, 400) 
開發者ID:DeepinSC,項目名稱:PyTorch-Luna16,代碼行數:27,代碼來源:data_processings.py

示例7: plot

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot(self, fig=None, ax=None, *args, **kwargs):
        p = self.polygon_list
        v = self.vertex_array
        if fig is None:
            fig = matplotlib.pyplot.gcf()
        if ax is None:
            ax = Axes3D(fig)
        if p:
            ax.add_collection3d(Poly3DCollection(p))
        if v.shape:
            ax.scatter(v[:, 0], v[:, 1], v[:, 2], *args, **kwargs)
        ax.set_xlabel('X')
        ax.set_ylabel('Y')
        ax.set_zlabel('Z')
        return fig, ax 
開發者ID:vinits5,項目名稱:pointnet-registration-framework,代碼行數:17,代碼來源:mesh.py

示例8: plot_3d_forest_rover

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_3d_forest_rover(roverdomain, rectangles, ntraj_points=100):
    from matplotlib import pyplot as plt
    from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection

    # get the cost of the current trajectory
    traj_cost = roverdomain.estimate_cost()

    # get points on the current trajectory
    traj_points = roverdomain.traj.get_points(np.linspace(0., 1.0, ntraj_points, endpoint=True))

    # convert the rectangles into lists of vertices for matplotlib
    poly3d, verts, faces = generate_verts(rectangles)

    ax = plt.gcf().add_subplot(111, projection='3d')

    # plot start and goal
    ax.scatter((roverdomain.start[0], roverdomain.goal[0]),
               (roverdomain.start[1], roverdomain.goal[1]),
               (roverdomain.start[2], roverdomain.goal[2]), c='k')

    # plot traj
    seg = (zip(traj_points[:-1, :], traj_points[1:, :]))
    ax.add_collection3d(Line3DCollection(seg, colors=[(0, 1., 0, 1.)] * len(seg)))

    # plot rectangles
    ax.add_collection3d(Poly3DCollection(poly3d, facecolors=(0.7, 0.7, 0.7, 1.), linewidth=0.5))

    # set limits of axis to be the same as domain
    s_range = roverdomain.s_range
    ax.set_xlim(s_range[0][0], s_range[1][0])
    ax.set_ylim(s_range[0][1], s_range[1][1])
    ax.set_zlim(s_range[0][2], s_range[1][2]) 
開發者ID:zi-w,項目名稱:Ensemble-Bayesian-Optimization,代碼行數:34,代碼來源:rover_utils.py

示例9: _make_collections

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def _make_collections(polygons, opacity=1):
    """Make collections from a dict of polygons."""
    collection = []
    for color in polygons:
        collection.append(
            Poly3DCollection(
                [p.points_matrix for p in polygons[color]],
                alpha=opacity,
                facecolor=color,
                edgecolors="black",
            )
        )
    return collection 
開發者ID:jamiebull1,項目名稱:geomeppy,代碼行數:15,代碼來源:view_geometry.py

示例10: plot_latent_trajectory

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_latent_trajectory(path_to_save_fig=None):
    fig = plt.figure()
    ax = Axes3D(fig)

    #vertices of simplex
    x = [0,0,1]
    y = [0,1,0]
    z = [1,0,0]
    verts = [zip(x,y,z)]


    #trajectory I made up
    xx=[[0.35, 0.2], [0.2, 0.32], [0.32, 0.25], [0.25, 0.1] ]
    yy=[[0.55, 0.5], [0.5,0.44],  [0.44,0.50], [0.50, 0.1]]
    zz=[[0.10, 0.1], [0.1, 0.16], [0.16, 0.25], [0.25, 0.8]]

    p=Poly3DCollection(verts, alpha=0.2)
    p.set_edgecolor('#000000')
    p.set_facecolor('#00FFFF')
    ax.add_collection3d(p)
    ax.view_init(30, 240)
    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")
    ax.invert_xaxis()
    ax.invert_yaxis()

    #make the simplex (plot each point + its index as text above)
    for i in range(len(x)): 
     ax.scatter(x[i],y[i],z[i] ,color='b', s=50) 
     ax.text(x[i],y[i],z[i], '(%d,%d,%d)' % (x[i],y[i],z[i]), size=10, zorder=1,  
     color='k') 
    #add in trajectory
    for (x,y,z) in zip(xx,yy,zz):
        ax.plot(x,y,z, 'k-o')
    #save or plot
    if path_to_save_fig:
        fig.savefig(path_to_save_fig)
    else:
        fig.show() 
開發者ID:cylance,項目名稱:winapi-deobfuscation,代碼行數:42,代碼來源:draw.py

示例11: add_mesh

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def add_mesh(ax, verts, faces, flip_x=False, c="b", alpha=0.1):
    ax.view_init(elev=90, azim=-90)
    mesh = Poly3DCollection(verts[faces], alpha=alpha)
    if c == "b":
        face_color = (141 / 255, 184 / 255, 226 / 255)
        edge_color = (0 / 255, 0 / 255, 112 / 255)
    elif c == "r":
        face_color = (226 / 255, 141 / 255, 141 / 255)
        edge_color = (112 / 255, 0 / 255, 0 / 255)
    elif c == "viridis":
        face_color = plt.cm.viridis(np.linspace(0, 1, faces.shape[0]))
        edge_color = None
        edge_color = (0 / 255, 0 / 255, 112 / 255)
    elif c == "plasma":
        face_color = plt.cm.plasma(np.linspace(0, 1, faces.shape[0]))
        edge_color = None
        # edge_color = (0 / 255, 0 / 255, 112 / 255)
    else:
        face_color = c
        edge_color = c

    mesh.set_edgecolor(edge_color)
    mesh.set_facecolor(face_color)
    ax.add_collection3d(mesh)
    cam_equal_aspect_3d(ax, verts, flip_x=flip_x)
    plt.tight_layout() 
開發者ID:hassony2,項目名稱:obman_train,代碼行數:28,代碼來源:displaymano.py

示例12: load_contacts

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def load_contacts(
    save_contact_paths="assets/contact_zones.pkl", display=False
):
    with open(save_contact_paths, "rb") as p_f:
        contact_data = pickle.load(p_f)
    hand_verts = contact_data["verts"]
    if display:
        colors = [
            "#f04e36",
            "#f36e27",
            ["#f3d430"],
            ["#1eb19d"],
            ["#ed1683"],
            ["#37bad6"],
        ]
        hand_faces = contact_data["faces"]
        fig = plt.figure()
        ax = fig.add_subplot(111, projection="3d")
        # Display hand and object meshes
        hand_mesh_disp = Poly3DCollection(hand_verts[hand_faces], alpha=0.1)
        hand_mesh_disp.set_edgecolor("k")
        hand_mesh_disp.set_facecolor([[1, 1, 1], [1, 0, 0]])
        ax.add_collection3d(hand_mesh_disp)
        idx_1, idx_2, idx_3 = 0, 1, 2
        ax.axis("off")
        # ax.scatter(hand_verts[:, idx_1], hand_verts[:, idx_2])
        for zone_idx, zone_vert_idxs in contact_data["contact_zones"].items():
            ax.scatter(
                hand_verts[zone_vert_idxs, idx_1],
                hand_verts[zone_vert_idxs, idx_2],
                hand_verts[zone_vert_idxs, idx_3],
                s=100,
                c=colors[zone_idx],
            )
        displaymano.cam_equal_aspect_3d(ax, hand_verts)
        plt.show()
    return hand_verts, contact_data["contact_zones"] 
開發者ID:hassony2,項目名稱:obman_train,代碼行數:39,代碼來源:contactutils.py

示例13: draw_3d_bbox_in_3dax

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def draw_3d_bbox_in_3dax(ax, bboxes, colors='r', alpha=0.25, facecolors=None):
    if not isinstance(colors, list):
        colors = [colors for i in range(len(bboxes))]
    if not isinstance(facecolors, list):
        facecolors = [facecolors for i in range(len(bboxes))]

    for box, color, facecolor in zip(bboxes, colors, facecolors):
        ax.scatter3D(box[:, 0], box[:, 1], box[:, 2], marker='.', color=color)
        verts = np.array([
            [box[0], box[1], box[2], box[3]],
            [box[4], box[5], box[6], box[7]],
            [box[0], box[3], box[7], box[4]],
            [box[1], box[2], box[6], box[5]],
            [box[0], box[1], box[5], box[4]],
            [box[3], box[2], box[6], box[7]],
        ])
        mp3dcoll = Poly3DCollection(
            verts,
            linewidths=1,
            edgecolors=color,
            alpha=alpha,
            facecolors=facecolor)
        mp3dcoll.set_facecolor(facecolor)
        mp3dcoll.set_edgecolor(color)
        mp3dcoll.set_alpha(alpha)
        ax.add_collection3d(mp3dcoll)
    return ax 
開發者ID:traveller59,項目名稱:second.pytorch,代碼行數:29,代碼來源:bbox_plot.py

示例14: plot_mesh

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def plot_mesh(mesh_path, workspace2obj, axis=None):
    """Visualize where we will sample grasp candidates from

    Parameters
    ----------
    mesh_path : path to a given mesh
    workspace2obj : 4x4 transform matrix from the workspace to object
    axis : (optional) a matplotlib axis for plotting a figure
    """

    if axis is None:
        figure = plt.figure()
        axis = Axes3D(figure)
        axis.autoscale(False)

    # Load the object mesh
    mesh = trimesh.load_mesh(mesh_path)

    # V-REP encodes the object centroid as the literal center of the object,
    # so we need to make sure the points are centered the same way
    center = calc_mesh_centroid(mesh, center_type='vrep')
    mesh.vertices -= center

    # Rotate the vertices so they're in the frame of the workspace
    mesh.apply_transform(workspace2obj)

    # Construct a 3D mesh via matplotlibs 'PolyCollection'
    poly = Poly3DCollection(mesh.triangles, linewidths=0.05, alpha=0.25)
    poly.set_facecolor([0.5, 0.5, 1])
    axis.add_collection3d(poly)

    return plot_equal_aspect(mesh.vertices, axis) 
開發者ID:mveres01,項目名稱:multi-contact-grasping,代碼行數:34,代碼來源:utils.py

示例15: show_mesh

# 需要導入模塊: from mpl_toolkits.mplot3d import art3d [as 別名]
# 或者: from mpl_toolkits.mplot3d.art3d import Poly3DCollection [as 別名]
def show_mesh(mesh):
    r"""
    Visualizes the mesh of a region as obtained by ``get_mesh`` function in
    the ``metrics`` submodule.

    Parameters
    ----------
    mesh : tuple
        A mesh returned by ``skimage.measure.marching_cubes``

    Returns
    -------
    fig : Matplotlib figure
        A handle to a matplotlib 3D axis
    """
    lim_max = np.amax(mesh.verts, axis=0)
    lim_min = np.amin(mesh.verts, axis=0)

    # Display resulting triangular mesh using Matplotlib.
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    # Fancy indexing: `verts[faces]` to generate a collection of triangles
    mesh = Poly3DCollection(mesh.verts[mesh.faces])
    mesh.set_edgecolor('k')

    ax.add_collection3d(mesh)
    ax.set_xlabel("x-axis")
    ax.set_ylabel("y-axis")
    ax.set_zlabel("z-axis")
    ax.set_xlim(lim_min[0], lim_max[0])
    ax.set_ylim(lim_min[1], lim_max[1])
    ax.set_zlim(lim_min[2], lim_max[2])

    return fig 
開發者ID:PMEAL,項目名稱:porespy,代碼行數:37,代碼來源:__plots__.py


注:本文中的mpl_toolkits.mplot3d.art3d.Poly3DCollection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。