当前位置: 首页>>代码示例>>Python>>正文


Python proj3d.proj_transform方法代码示例

本文整理汇总了Python中mpl_toolkits.mplot3d.proj3d.proj_transform方法的典型用法代码示例。如果您正苦于以下问题:Python proj3d.proj_transform方法的具体用法?Python proj3d.proj_transform怎么用?Python proj3d.proj_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpl_toolkits.mplot3d.proj3d的用法示例。


在下文中一共展示了proj3d.proj_transform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_ellipses

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def make_ellipses(gmm, ax):
    import matplotlib as mpl
    from mpl_toolkits.mplot3d import proj3d

    for n, color in enumerate('rgb'):
        v, w = np.linalg.eigh(gmm.covariances_[n][:2, :2])
        u = w[0] / np.linalg.norm(w[0])
        angle = np.arctan2(u[1], u[0])
        angle = 180 * angle / np.pi  # convert to degrees
        v *= 9
        x, y, z = gmm.means_[n, :3]
        x2, y2, _ = proj3d.proj_transform(x,y,z, ax.get_proj())
        ell = mpl.patches.Ellipse([x2, y2], v[0], v[1],
                                  180 + angle, color=color)
        ell.set_clip_box(ax.bbox)
        ell.set_alpha(0.5)
        ax.add_artist(ell) 
开发者ID:pelednoam,项目名称:mmvt,代码行数:19,代码来源:utils.py

示例2: draw

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
        FancyArrowPatch.draw(self, renderer) 
开发者ID:jiacheng-xu,项目名称:vmf_vae_nlp,代码行数:7,代码来源:draw_gauss_ball.py

示例3: draw

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def draw(self, renderer):
            """Draw the arrow."""
            xs3d, ys3d, zs3d = self._verts3d
            xs, ys, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
            self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
            FancyArrowPatch.draw(self, renderer) 
开发者ID:Qiskit,项目名称:qiskit-terra,代码行数:8,代码来源:state_visualization.py

示例4: draw

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def draw(self, renderer):
        xs3d, ys3d, zs3d = self._verts3d
        xs, ys, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
        self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
        FancyArrowPatch.draw(self, renderer)


############################################################################### 
开发者ID:empymod,项目名称:empymod,代码行数:10,代码来源:coordinate_system.py

示例5: annotate_point

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def annotate_point(figure, axes, x, y, z, color):
    xp1, yp1, _ = proj3d.proj_transform(x, y, z, axes.get_proj())
    label = axes.annotate(
        '{:.5g}'.format(z), xy=(xp1, yp1), xytext = (-20, 40),
        textcoords = 'offset points', ha = 'right', va = 'bottom',
        bbox = dict(boxstyle='round,pad=0.5', fc=color, alpha=0.5),
        arrowprops = dict(arrowstyle='->', connectionstyle='arc3,rad=0',
                          color=color))

    def update_position(_):
        xp2, yp2, _ = proj3d.proj_transform(x, y, z, axes.get_proj())
        label.xy = xp2, yp2
        label.update_positions(figure.canvas.renderer)
        figure.canvas.draw()
    figure.canvas.mpl_connect('button_release_event', update_position) 
开发者ID:JanCVanB,项目名称:netflix,代码行数:17,代码来源:graph_rmse.py

示例6: add_annotation

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def add_annotation(ax, text, x, y, z=None):
    from mpl_toolkits.mplot3d import proj3d
    import pylab
    if not z is None:
        x2, y2, _ = proj3d.proj_transform(x,y,z, ax.get_proj())
    else:
        x2, y2 = x, y
    pylab.annotate(
        text, xy = (x2, y2), xytext = (-20, 20),
        textcoords = 'offset points', ha = 'right', va = 'bottom',
        bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
        arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')) 
开发者ID:pelednoam,项目名称:mmvt,代码行数:14,代码来源:utils.py

示例7: draw

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def draw(self, renderer):
            """Draw the patch."""
            xs3d, ys3d, zs3d = self._verts3d
            xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
            self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
            super(Arrow3D, self).draw(renderer) 
开发者ID:rock-learning,项目名称:pytransform3d,代码行数:8,代码来源:plot_utils.py

示例8: plot_samples_3D

# 需要导入模块: from mpl_toolkits.mplot3d import proj3d [as 别名]
# 或者: from mpl_toolkits.mplot3d.proj3d import proj_transform [as 别名]
def plot_samples_3D(self):
        """
        Plots the orientations in a sphere.
        Returns: Nothing, it just plots.
        """
        # (this code is partially from stackoverflow)
        fig = plt.figure(figsize=[5, 5])
        ax = fig.gca(projection='3d')
        ax.set_aspect("equal")
        ax.view_init(azim=30)

        # render the sphere mesh
        u, v = np.mgrid[0:2 * np.pi:20j, 0:np.pi:10j]
        # print(u,v)
        x = np.cos(u) * np.sin(v)
        y = np.sin(u) * np.sin(v)
        z = np.cos(v)
        ax.plot_wireframe(x, y, z, color="lightgray")
        plt.axis('on')

        # coordinate system in centre of sphere
        origin = [0, 0, 0]
        X, Y, Z = [1, 0, 0], [0, 1, 0], [0, 0, 1]
        O, O, O = zip(origin, origin, origin)
        X, Y, Z = zip(X, Y, Z)
        ax.quiver(O, O, O, X, Y, Z, arrow_length_ratio=0.1, color='k')

        ax.set_xlabel('X')
        ax.set_ylabel('Y')
        ax.set_zlabel('Z')

        class Arrow3D(FancyArrowPatch):
            def __init__(self, xs, ys, zs, *args, **kwargs):
                FancyArrowPatch.__init__(self, (0, 0), (0, 0), *args, **kwargs)
                self._verts3d = xs, ys, zs

            def draw(self, renderer):
                xs3d, ys3d, zs3d = self._verts3d
                xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
                self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
                FancyArrowPatch.draw(self, renderer)

        # Plot arrows
        for i in self.samples_xyz:
            ax.add_artist(Arrow3D([0, i[0]], [0, i[1]], [0, i[2]], mutation_scale=20, lw=1, arrowstyle="-|>",
                                  color="darkgreen"))  # samples
        try:
            ax.add_artist(
                Arrow3D([0, self.mean[0]], [0, self.mean[1]], [0, self.mean[2]], mutation_scale=20, lw=1, arrowstyle="-|>",
                        color="darkorange"))  # mean
        except AttributeError:
            pass
        plt.show()
        return fig 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:56,代码来源:fishdist.py


注:本文中的mpl_toolkits.mplot3d.proj3d.proj_transform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。