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


Python Ellipse.get_verts方法代码示例

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


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

示例1: error_ellipse

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import get_verts [as 别名]
    def error_ellipse(self, i, j, nstd=1, space_factor=5.0, clr="b", alpha=0.5, lw=1.5):
        """
        return the plot of the error ellipse from the covariance matrix
        use ideas from error_ellipse.m from
        http://www.mathworks.com/matlabcentral/fileexchange/4705-error-ellipse
        ( the version used here was taken from an earlier version, it looks to have been updated there to a new version.)

        * (i,j) specify the ith and jth parameters to be used and
        * nstd specifies the number of standard deviations to plot, the default is 1 sigma.
        * space_factor specifies the number that divides the width/height, the result of which is then added as extra space to the figure
        """

        def eigsorted(cov):
            vals, vecs = np.linalg.eigh(cov)
            order = vals.argsort()[::1]
            return vals[order], vecs[:, order]

        self.marginalize(param_list=[i, j])
        vals, vecs = eigsorted(self.marginal_covariance_matrix)
        theta = np.degrees(np.arctan2(*vecs[:, 0][::-1]))
        # print theta
        width, height = 2 * nstd * np.sqrt(vals)
        xypos = [self.parameter_values[i], self.parameter_values[j]]
        ellip = Ellipse(xy=xypos, width=width, height=height, angle=theta, color=clr, alpha=alpha)
        # ellip.set_facecolor("white")
        ellip.set_linewidth(lw)
        ellip_vertices = ellip.get_verts()
        xl = [ellip_vertices[k][0] for k in range(len(ellip_vertices))]
        yl = [ellip_vertices[k][1] for k in range(len(ellip_vertices))]
        dx = (max(xl) - min(xl)) / space_factor
        dy = (max(yl) - min(yl)) / space_factor
        xyaxes = [min(xl) - dx, max(xl) + dx, min(yl) - dy, max(yl) + dy]
        return ellip, xyaxes
开发者ID:sarojadhikari,项目名称:fishercode,代码行数:35,代码来源:fisher.py


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