adasurf.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:PyGeo 作者: CalvinNeo 项目源码 文件源码
def paint_surfs(surfs, points, show = True, title = ''):
    fig = pl.figure()
    ax = fig.add_subplot(111, projection='3d')
    xlim = (np.min(points[:, 0]), np.max(points[:, 0]))
    ylim = (np.min(points[:, 1]), np.max(points[:, 1]))
    zlim = (np.min(points[:, 2]), np.max(points[:, 2]))
    for ans, surf_id in zip(surfs, range(len(surfs))):
        a, b, c = ans.args[0], ans.args[1], ans.args[2]
        X = np.arange(xlim[0], xlim[1], (xlim[1]-xlim[0])/100.0)
        Y = np.arange(ylim[0], ylim[1], (ylim[1]-ylim[0])/100.0)
        X, Y = np.meshgrid(X, Y)
        Z = -(X*a + Y*b + c)
        s = ax.plot_wireframe(X, Y, Z, rstride=15, cstride=15)
        x1 = ans.points[:, 0]
        y1 = ans.points[:, 1]
        z1 = ans.points[:, 2]
        ax.scatter(x1, y1, z1, c='rcykgm'[surf_id % 6], marker='o^sd*+xp'[int(surf_id/6)])

    ax.set_zlim(zlim[0], zlim[1])
    # ax.set_ylim(ylim[0], ylim[1])
    # ax.set_xlim(xlim[0], xlim[1])
    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")
    ax.zaxis.set_major_locator(LinearLocator(10))
    ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
    pl.title(title)
    if show:
        pl.show()
    return fig
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号