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


Python Ellipse.set_label方法代码示例

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


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

示例1: TestSingleCellPlot

# 需要导入模块: from matplotlib.patches import Ellipse [as 别名]
# 或者: from matplotlib.patches.Ellipse import set_label [as 别名]
def TestSingleCellPlot(extractor):

    extractor.basic_props(splineSmooth)
    extractor.shape_props()
    extractor.cell_centre_fit()
    
    padding = 10

    fixed_perim = NP.transpose(extractor.perim_img)

    perim_img_ind = NP.where(fixed_perim == 1)

    xlim_min = min(perim_img_ind[1])
    xlim_max = max(perim_img_ind[1])

    ylim_min = min(perim_img_ind[0])
    ylim_max = max(perim_img_ind[0])

    U = extractor.spl_u
    OUT = interpolate.splev(U, extractor.spl_poly)
    BDY_FEATS = extractor.bdy_fvector

    # Create Circle/Ellipse plot
    fig = PLT.figure(1)
    ax = fig.add_subplot(111, aspect='equal')

    # Create circle plot
    c = PLT.Circle((extractor.ccm_fvector[0],
            extractor.ccm_fvector[1]),
            extractor.ccm_fvector[2])
            
    xlim_min = min(xlim_min, extractor.ccm_fvector[0] - extractor.ccm_fvector[2])
    xlim_max = max(xlim_max, extractor.ccm_fvector[0] + extractor.ccm_fvector[2])
    ylim_min = min(ylim_min, extractor.ccm_fvector[1] - extractor.ccm_fvector[2])
    ylim_max = max(ylim_max, extractor.ccm_fvector[1] + extractor.ccm_fvector[2])

    # Create ellipse plot
    e = Ellipse(xy=NP.array([extractor.ellipse_fvector[0], extractor.ellipse_fvector[1]]),
            width = extractor.ellipse_fvector[4],
            height = extractor.ellipse_fvector[3],
            angle = extractor.ellipse_fvector[5]/(2*NP.pi)*360)

    # Compute horizontal width and height of the oriented ellipse
    a = extractor.ellipse_fvector[4]/2.0
    b = extractor.ellipse_fvector[3]/2.0
    alpha = extractor.ellipse_fvector[5]
    x_c = extractor.ellipse_fvector[0]
    y_c = extractor.ellipse_fvector[1]
    x_b = 0
    y_b = 0
    if a > b:
        x_b = abs(a * math.cos(alpha))
        y_b = abs(a * math.cos(alpha))
    else:
        x_b = abs(b * math.sin(alpha))
        y_b = abs(b * math.cos(alpha))
        
    xlim_min = min(xlim_min, x_c - x_b)
    xlim_max = max(xlim_max, x_c + x_b)
    ylim_min = min(ylim_min, y_c - y_b)
    ylim_max = max(ylim_max, y_c + y_b)

    PLT.imshow(fixed_perim, interpolation='nearest', cmap='Greys')
    perimeter = conv_distance(extractor.perim_3pv)[0]
    PLT.xticks([])
    PLT.yticks([])
    PLT.plot(extractor.perim_coord_poly[:,0], extractor.perim_coord_poly[:,1], label='Polygon Fit (Perimeter = %.2f um)'%perimeter, color='g', lw=2)

    ax.add_artist(c)
    c.set_alpha(1)
    c.set_facecolor('none')
    c.set_edgecolor('blue')
    c.set_linewidth(3)
    c.set_label('Circle')

    ax.add_artist(e)
    e.set_alpha(1)
    e.set_facecolor('none')
    e.set_edgecolor('orange')
    e.set_linewidth(3)
    e.set_label('Ellipse')
    
    PLT.plot(0, 0, color='blue', label='Circle Fit (Variance = %.2f)'%extractor.ccm_fvector[5], lw=2)
    PLT.plot(0, 0, color='orange', label='Ellipse Fit (Variance = %.2f)'%extractor.ellipse_fvector[8], lw=2)

    lgd = PLT.legend(bbox_to_anchor=(0.0, 1.1, 1.0, 1.5), loc=3, ncol=1, mode=None, fontsize="small", borderaxespad=0.2, fancybox=True, shadow=True)
    
    ax.set_xlim([xlim_min - padding, xlim_max + padding])
    ax.set_ylim([ylim_min - padding, ylim_max + padding])
    
    PLT.xticks([])
    PLT.yticks([])
    
    PLT.savefig(outFolder + pifFileName + '_Fits.png', bbox_extra_artists=(lgd,), bbox_inches='tight', dpi = 400)

    # Create spline plot with boundary color based on magnitude and parity of curvature
    fig, (ax1, ax2) = PLT.subplots(1, 2, gridspec_kw = {'width_ratios':[1,10]})
    knorm = expit(extractor.spl_k/max(abs(extractor.spl_k))*10)
    
    norm = matplotlib.colors.Normalize(vmin=NP.min(extractor.spl_k), vmax=NP.max(extractor.spl_k))
#.........这里部分代码省略.........
开发者ID:dbhaskar92,项目名称:Research-Scripts,代码行数:103,代码来源:pif_extract_features.py


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