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


Python SubplotHost.set_title方法代码示例

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


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

示例1: plotcomplexpolar

# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_title [as 别名]
def plotcomplexpolar(metaAry, size = (10, 7.5), dpi = 75, grid = True, legend = 0, fontsize = 15):
    """
    metaArray function to do a simple 1D plot of complex array as magnitude and phase angle.
    
    legend:
        'best'  0
        'upper right'   1
        'upper left'    2
        'lower left'    3
        'lower right'   4
        'right'         5
        'center left'   6
        'center right'  7
        'lower center'  8
        'upper center'  9
        'center'        10
    """
    
    if legend is None:
        legend = 0
    
    axis = metaAry['range']    
    mag = abs(metaAry.data)
    pha = angle(metaAry.data, deg=True)
    
    # Load the plotting ranges and units
    x0 = axis['begin'][0]
    x1 = axis['end'][0]
    my0 = min(mag)
    my1 = max(mag)
    py0 = min(pha)
    py1 = max(pha)
    xunit = axis['unit'][0]
    myunit = metaAry['unit']
    pyunit = 'Degree'
    
    # Leave 10% margin in the y axis
    mmean = average((my0, my1))
    mreach = abs(my0-my1) / 2 / 0.9
    my0 = sign(my0-mmean) * mreach + mmean
    my1 = sign(my1-mmean) * mreach + mmean
    
    pmean = average((py0, py1))
    preach = abs(py0-py1) / 2 / 0.9
    py0 = sign(py0-pmean) * preach + pmean
    py1 = sign(py1-pmean) * preach + pmean
    
    # Apply unit prefix if unit is defined
    xunit, x0, x1, xscale = prettyunit(xunit, x0, x1)
    myunit, my0, my1, myscale = prettyunit(myunit, my0, my1)
    pyunit, py0, py1, pyscale = prettyunit(pyunit, py0, py1)
    
    if myscale != 1:
        mag = mag * myscale
        
    if pyscale != 1:
        pha = pha.copy() * pyscale
        
    xlabl = lbl_repr(axis['label'][0], xunit)
    mylabl = lbl_repr(metaAry['label'], myunit, "Magnitude")
    pylabl = lbl_repr(metaAry['label'], pyunit, "Phase angle")
    
    title = metaAry['name']
    
    fig = figure(figsize=size, dpi = dpi)
    host = SubplotHost(fig, 111)
    
    fig.add_subplot(host)
    par = host.twinx()
    
    if axis['log'][0] is False:
        x = linspace(x0, x1, len(metaAry))
    else:
        raise NotImplemented, "Log axis is not yet implemented."
    
    host.plot(x, mag, 'b-', label=lbl_repr(axis['label'][0], '', "Magnitude"))
    par.plot(x, pha, 'r--', label=lbl_repr(axis['label'][0], '', "Phase"))
    
    host.grid(grid)
    
    host.set_xlabel(xlabl, fontsize=fontsize)
    host.set_ylabel(mylabl, fontsize=fontsize)
    par.set_ylabel(pylabl, fontsize=fontsize)
    
    host.set_xlim([x0, x1])
    host.set_ylim([my0, my1])
    par.set_ylim([py0, py1])
    
    if fontsize is not None:
        host.set_title(title, fontsize=int(fontsize*1.3))
    else:
        host.set_title(title)
        
    if legend >= 0:
        host.legend(loc=legend)
    
    return fig, host, par
开发者ID:Charley-fan,项目名称:metaArray,代码行数:99,代码来源:drv_pylab.py

示例2: plotcomplex

# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_title [as 别名]
def plotcomplex(metaAry, size = (10, 7.5), dpi = 75, grid = True, legend = 0, fontsize = 15):
    """
    metaArray function to do a simple 1D plot of complex array as real and imaginary parts.
    
    legend:
        'best'  0
        'upper right'   1
        'upper left'    2
        'lower left'    3
        'lower right'   4
        'right'         5
        'center left'   6
        'center right'  7
        'lower center'  8
        'upper center'  9
        'center'        10
    """
    
    if legend is None:
        legend = 0
    
    axis = metaAry['range']
    rdata = metaAry.data.real
    idata = metaAry.data.imag
    
    # Load the plotting ranges and units
    x0 = axis['begin'][0]
    x1 = axis['end'][0]
    ry0 = min(rdata)
    ry1 = max(rdata)
    iy0 = min(idata)
    iy1 = max(idata)
    xunit = axis['unit'][0]
    ryunit = metaAry['unit']
    iyunit = metaAry['unit']
    
    # Leave 10% margin in the y axis
    rmean = average((ry0, ry1))
    rreach = abs(ry0-ry1) / 2 / 0.9
    ry0 = sign(ry0-rmean) * rreach + rmean
    ry1 = sign(ry1-rmean) * rreach + rmean
    
    imean = average((iy0, iy1))
    ireach = abs(iy0-iy1) / 2 / 0.9
    iy0 = sign(iy0-imean) * ireach + imean
    iy1 = sign(iy1-imean) * ireach + imean
    
    # Apply unit prefix if unit is defined
    xunit, x0, x1, xscale = prettyunit(xunit, x0, x1)
    ryunit, ry0, ry1, ryscale = prettyunit(ryunit, ry0, ry1)
    iyunit, iy0, iy1, iyscale = prettyunit(iyunit, iy0, iy1)
    
    if ryscale != 1:
        rdata = rdata.copy() * ryscale
        
    if iyscale != 1:
        idata = idata.copy() * iyscale
        
    xlabl = lbl_repr(axis['label'][0], xunit)
    rylabl = lbl_repr(metaAry['label'], ryunit, "Real part")
    iylabl = lbl_repr(metaAry['label'], iyunit, "Imaginary part")
    
    title = metaAry['name']
    
    fig = figure(figsize=size, dpi = dpi)
    host = SubplotHost(fig, 111)
    
    fig.add_subplot(host)
    par = host.twinx()
    
    if axis['log'][0] is False:
        x = linspace(x0, x1, len(metaAry))
    else:
        raise NotImplemented, "Log axis is not yet implemented."
    
    host.plot(x, rdata, 'b-', label=lbl_repr(axis['label'][0], '', "Real"))
    par.plot(x, idata, 'r--', label=lbl_repr(axis['label'][0], '', "Imaginary"))
    
    host.grid(grid)
    
    host.set_xlabel(xlabl, fontsize=fontsize)
    host.set_ylabel(rylabl, fontsize=fontsize)
    par.set_ylabel(iylabl, fontsize=fontsize)
    
    host.set_xlim([x0, x1])
    host.set_ylim([ry0, ry1])
    par.set_ylim([iy0, iy1])
    
    if fontsize is not None:
        host.set_title(title, fontsize=int(fontsize*1.3))
    else:
        host.set_title(title)
        
    if legend >= 0:
        host.legend(loc=legend)
    
    return fig, host, par
开发者ID:Charley-fan,项目名称:metaArray,代码行数:99,代码来源:drv_pylab.py


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