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


Python PlotUtilities.secondAxis方法代码示例

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


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

示例1: format_kcal_per_mol_second_axis_after_kT_axis

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import secondAxis [as 别名]
def format_kcal_per_mol_second_axis_after_kT_axis():
    """
    formats a second, kcal/mol axis after plotting kT data 
    """
    ax_kT = plt.gca()
    ylim_kcal_per_mol = get_limit_kcal_per_mol(ax_kT)
    ax_kcal = PlotUtilities.secondAxis(ax=ax_kT,label="Energy (kcal/mol)",
                                       limits=ylim_kcal_per_mol,color='b',
                                       secondY=True)
    _set_kcal_axis_based_on_kT(ax_kT,ax_kcal)
    plt.sca(ax_kT)                       
    return ax_kcal
开发者ID:prheenan,项目名称:Research,代码行数:14,代码来源:IWT_Plot.py

示例2: dict

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import secondAxis [as 别名]
 """        
 keywords_iwt = dict(UnfoldingObjs=unfold,NumBins=150,RefoldingObjs=refold)
 landscape = CheckpointUtilities.\
     getCheckpoint(rel + "landscape.pkl",
                   InverseWeierstrass.FreeEnergyAtZeroForce,
                   False,**keywords_iwt)
 L0_gc_poor_nm = 0.67 * (100 - 4 - 16*2)
 linker_lengths_nm = 3.2*2
 for f in [6e-12,8e-12,12e-12,16e-12]:
     tilted = IWT_Util.TiltedLandscape(landscape,f_one_half_N=f)   
     fig = PlotUtilities.figure()    
     ax = plt.subplot(2,1,1)    
     plt.plot(landscape.Extensions*1e9,landscape.EnergyLandscape/4.1e-21)
     ylim = np.array(plt.ylim())
     PlotUtilities.lazyLabel("","Free Landscape (kT)","")    
     PlotUtilities.secondAxis(ax,label="kcal/mol",limits=ylim*0.529)
     PlotUtilities.no_x_label()
     ax = plt.subplot(2,1,2)
     plt.plot(tilted.landscape_ext_nm,tilted.OffsetTilted_kT)
     plt.axvline(L0_gc_poor_nm,linestyle=':',linewidth=3,color='g',
                 label="L$_0$ (GC poor)")
     linker_kw = dict(color='r',linestyle='--',linewidth=3)
     plt.axvline(L0_gc_poor_nm+linker_lengths_nm,label="$\pm$ Linkers",
                 **linker_kw)
     plt.axvline(L0_gc_poor_nm-linker_lengths_nm,**linker_kw)
     
     y= ("Tilted (kT)(tilt: {:.2g}pN)".format(f*1e12))
     plt.ylim([-10,60])
     PlotUtilities.lazyLabel("Extension (nm)",y,"",frameon=True)
     ylim = np.array(plt.ylim())
     PlotUtilities.secondAxis(ax,label="kcal/mol",limits=ylim*0.529)        
开发者ID:prheenan,项目名称:Research,代码行数:33,代码来源:main_hairpin_100nt_initial.py

示例3: run

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import secondAxis [as 别名]

#.........这里部分代码省略.........
    UpperBoundDist = upper_bound_func(tip_radius_nm,DNASizeNanoMeters)
    plt.loglog(LoadConcentrationNgPerUl,LowerEfficiency,
               'm.-',linewidth=3,
               label="{:d}% efficiency".format(int(efficiency*100)))
    # bit of a hack to get the label working
    xlabel =("Concentration [ng/uL]" +\
             "\n({:d}uL Deposition onto {:.1f}mm diameter glass)").\
        format(LoadVolumeMicroliters,(2*radius)*1000)
    pPlotUtil.lazyLabel(xlabel,
                        "Expected Mean DNA distance [nm]",
                        "Tuning Deposition Concentration to avoid dimerization",
                        titley=1.1)
    LegendAndSave(fig,"DepositionAdvice1.png")
    plt.axvspan(xmin=MaxConcNgPerUl,xmax=plt.xlim()[-1],color='r',alpha=0.3,
                label="Impossible prep")
    plt.axhspan(ymin=plt.ylim()[0],ymax=LowerBoundDist,color='k',
                alpha=0.3)
    plt.axhspan(ymin=UpperBoundDist,ymax=plt.ylim()[-1],color='k',alpha=0.3,
                label="Suboptimal for AFM")
    # our circular DNA is roughly 607nm
    plt.axhline(DNASizeNanoMeters,linewidth=4,linestyle='--',
                label="L0={:.1f}nm".format(DNASizeNanoMeters))
    LegendAndSave(fig,"DepositionAdvice2.png")
    IdealLoad = ((PerfectEfficiency > LowerBoundDist) &
                 (LowerEfficiency < UpperBoundDist))
    WhereIdealIdx = np.where(IdealLoad)
    plt.fill_between(LoadConcentrationNgPerUl,y1=LowerEfficiency,
                     y2=PerfectEfficiency,
                     where=IdealLoad,
                     facecolor='k')
    plt.plot([], [], color='black', linewidth=15,label="Ideal Loading")
    LegendAndSave(fig,"DepositionAdvice3.png")
    Molar= [NanoMolarLoaded[0],NanoMolarLoaded[-1]]
    pPlotUtil.secondAxis(ax1,"Molarity (nM)",limits=Molar,color="Blue",
                         secondY=False)
    plt.xlabel("Concentration (ng/uL)")
    plt.tight_layout()
    pPlotUtil.savefig(fig,output_base + "DepositionAdvice4.png")
    """
    We load the 20uL into xuL of TE and heat; what volume should we use?
    """
    MaxMolarity = MolarityLoaded[WhereIdealIdx[0][0]]
    MinVolLog = np.log10(LoadVolumeMicroliters * 1e-6)
    MaxVolLog = np.log10(LoadVolumeMicroliters* 1e-6 * 100)
    DepositionVolumesLiters = np.logspace(MinVolLog,MaxVolLog)
    # get the total number of molecules, given we load XXuL
    TotalMolecules = (MaxMolarity*Avogadro)*(LoadVolumeMicroliters*1e-6)
    # get the spacing of these, as a function of the volume
    LoadVolumesMeters = DepositionVolumesLiters * 1e-3
    MeanVolume = LoadVolumesMeters/TotalMolecules
    MeanSpacingMeters = (MeanVolume * (3/(4*np.pi)))**(1/3)
    MeanSpacingNanoMeters = MeanSpacingMeters*1e9
    MeanSpacingRadiusOfGyr = MeanSpacingNanoMeters/RadiusOfGyrLinearNanoMeters
    # plot the mean spacing, in terms of radius of gyration, in terms of the
    # deposition volume
    fig = pPlotUtil.figure()
    NumRadii = 20
    ExtraMicroLiters = 30
    plt.plot(DepositionVolumesLiters * 1e6,MeanSpacingRadiusOfGyr,
             label="Mean spacing between DNA")
    plt.axvline(LoadVolumeMicroliters+ExtraMicroLiters,linewidth=3,color='r',
                label="20uL (Sample) + {:d}uL (TE) deposition".\
                format(ExtraMicroLiters))
    plt.axhline(NumRadii,linewidth=3,color='b',
                label="{:d} Radii of Gyration (Linear DNA)".format(NumRadii))
    plt.axhline(DNASizeNanoMeters/RadiusOfGyrLinearNanoMeters,
开发者ID:prheenan,项目名称:Research,代码行数:70,代码来源:DepositionUtil.py

示例4: plot_landscape

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import secondAxis [as 别名]
def plot_landscape(data,xlim,kw_landscape=dict(),plot_derivative=True,
                   zero_q=True,
                   label_deltaG = PlotUtilities.variable_string("\Delta G")):
    landscape_kcal_per_mol = data.mean_landscape_kcal_per_mol
    landscape_kcal_per_mol -= min(landscape_kcal_per_mol)
    std_landscape_kcal_per_mol = data.std_landscape_kcal_per_mol
    extension_nm = data._extension_grid_nm
    if (zero_q):
        extension_nm -= min(extension_nm)
    extension_aa = data.amino_acids_per_nm() * extension_nm
    grad = lambda x: np.gradient(x)/(np.gradient(extension_aa))
    delta_landscape_kcal_per_mol_per_amino_acid = grad(landscape_kcal_per_mol)
    landscape_upper = landscape_kcal_per_mol+std_landscape_kcal_per_mol
    landscape_lower =landscape_kcal_per_mol-std_landscape_kcal_per_mol
    delta_landscape_kcal_per_mol_per_amino_acid = \
        data.mean_delta_landscape_kcal_per_mol_per_AA
    std_delta_landscape_kcal_per_mol_per_AA = \
        data.std_delta_landscape_kcal_per_mol_per_AA
    upper_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid+\
                            std_delta_landscape_kcal_per_mol_per_AA
    lower_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid-\
                            std_delta_landscape_kcal_per_mol_per_AA
    # make a second axis for the number of ammino acids 
    limits_delta = [min(delta_landscape_kcal_per_mol_per_amino_acid),
                    max(delta_landscape_kcal_per_mol_per_amino_acid)]    
    limits_energy = [min(landscape_kcal_per_mol),max(landscape_kcal_per_mol)]
    units_energy_delta = label_deltaG + \
                         r" per AA (kcal/(mol $\cdot$ AA))"   
    units_energy = PlotUtilities.unit_string("\Delta G","kcal/mol")                         
    difference_color = 'rebeccapurple'    
    landscape_color = kw_landscape['color']
    if (plot_derivative):
        PlotUtilities.lazyLabel("Extension (nm)",units_energy_delta,"")
        PlotUtilities.ylabel(units_energy_delta,color=difference_color)
    else:
        PlotUtilities.lazyLabel("Extension (nm)","","")  
        PlotUtilities.ylabel(units_energy,color=landscape_color)       
    # the derivative goes on the main axis in this case...
    if (plot_derivative):
        ax_delta = plt.gca()
        ax_2 = PlotUtilities.secondAxis(ax_delta,
                                        label=units_energy,color=landscape_color,
                                        limits=limits_energy,secondY =True,
                                        tick_color=landscape_color)
        ax_energy = ax_2
        to_ret = ax_delta,ax_energy
    else:
        ax_energy = plt.gca()
        ax_delta = None
        to_ret = ax_energy
    # filter the data if we need to 
    if (xlim is not None and xlim[1] is not None):
        idx= np.where( (extension_nm > xlim[0]) & (extension_nm < xlim[1]))
    else:
        idx =np.arange(extension_nm.size)
    # plot the landscape and its standard deviation
    ax_energy.plot(extension_nm[idx],landscape_kcal_per_mol[idx],
                   label=label_deltaG,zorder=10,**kw_landscape)
    ax_energy.fill_between(x=extension_nm[idx],
                           y1=landscape_lower[idx],
                           y2=landscape_upper[idx],
                           alpha=0.15,zorder=10,**kw_landscape)      
    # the energy y label should be rotated if it is on the right                            
    rotation = -90    
    if plot_derivative:
        kw_y = dict(rotation=-90,x=-0.3)
    else:
        kw_y = dict()
    PlotUtilities.ylabel(ax=ax_energy,lab=units_energy,**kw_y)
    # move the y label to the right slightly i we are using both axes 
    if plot_derivative:
        ax_energy.yaxis.set_label_coords(1.2,0.5)
    if (plot_derivative):                           
        # plot the energy delta and its bounds, based on the bounds on the
        #        landscape    
        ax_delta.plot(extension_nm[idx],
                      delta_landscape_kcal_per_mol_per_amino_acid[idx],
                      color=difference_color,linestyle='-',linewidth=1.5)
        PlotUtilities.color_axis_ticks(color=landscape_color,ax=ax_energy,
                                       spine_name='right')   
        ax_delta.fill_between(x=extension_nm[idx],
                              y1=lower_delta_landscape[idx],
                              y2=upper_delta_landscape[idx],
                              alpha=0.15,color=difference_color)                                           

    return to_ret
开发者ID:prheenan,项目名称:Research,代码行数:88,代码来源:main_landscapes.py

示例5: run

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import secondAxis [as 别名]
def run():
    """
    <Description>

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    base = FEC_Util.default_data_root()
    # XXX use Haos...
    absolute_data_dir = "./data_in/"
    out_base = "./"
    fraction_for_vel = 0.1
    # get the region near the first peak
    data_iwt = \
        CheckpointUtilities.getCheckpoint("./peaks.pkl",
                                          get_first_peak_slices,
                                          False,
                                          absolute_data_dir)                                   
    kwargs_fit = dict(kbT = 4.11e-21,
                      Lp=0.3e-9,
                      K0=1000e-12)                            
    # get the contour lengths                                                 
    contour_lengths = \
        CheckpointUtilities.getCheckpoint("./contour.pkl",
                                          get_contour_lengths,False,
                                          data_iwt,
                                          kwargs_fit)                                            
    # align all of them so that the contour length is at 0+x
    offset_nm = 0
    iwt_offset = []
    for d,L0 in zip(data_iwt,contour_lengths):
        tmp = copy.deepcopy(d)
        tmp.Extension -= (L0 - offset_nm)
        iwt_offset.append(tmp)
    # plot *all* of the data, along with the WLC fits...
    for i,(r,x0) in enumerate(zip(data_iwt,contour_lengths)):
        sep,force = r.Separation,r.Force
        grid_x,grid_y,predicted_force = \
            WLC.inverted_wlc(sep,force,x0,**kwargs_fit)   
        fig = PlotUtilities.figure()
        FEC_Plot._fec_base_plot(sep*1e9,force*1e12)
        plt.plot(grid_x*1e9,grid_y*1e12,color='r')
        PlotUtilities.lazyLabel("Separation","Force","")
        PlotUtilities.savefig(fig,"./{:d}_FEC.png".format(i))
    # plot the data before aligning
    fig = PlotUtilities.figure()
    FEC_Plot.heat_map_fec(data_iwt)
    PlotUtilities.savefig(fig,"heatmap_before.png")                 
    # plot the data after aligning
    fig = PlotUtilities.figure()
    FEC_Plot.heat_map_fec(iwt_offset)
    PlotUtilities.savefig(fig,"heatmap_after.png")       
    # POST: they are all set. get the IWT 
    num_bins = 250
    pr = cProfile.Profile()
    pr.enable()
    LandscapeObj =  InverseWeierstrass.\
        FreeEnergyAtZeroForce(iwt_offset,NumBins=num_bins)
    pr.disable()
    pr.print_stats(sort='time') 
    force_N = [1e-12,5e-12,10e-12,20e-12,40e-12,100e-12,250e-12,500e-12]
    max_extension_nm = max([max(f.Separation) for f in iwt_offset]) * 1e9
    ylim_kT = [-5,None]
    for i,f in enumerate(force_N):  
        xlim_nm = [min(LandscapeObj.Extensions)*1e9,
                   max_extension_nm]
        fig = PlotUtilities.figure(figsize=(6,12))
        kw_landscape = dict(f_one_half_N=f)
        # # plot the heat map after aligning
        plt.subplot(3,1,1)
        FEC_Plot.heat_map_fec(iwt_offset,use_colorbar=False)
        PlotUtilities.xlabel("")
        plt.xlim(xlim_nm)
        # # plot the free and tilted landscape
        ax_free = plt.subplot(3,1,2)
        IWT_Plot.plot_free_landscape(LandscapeObj,**kw_landscape)  
        PlotUtilities.xlabel("")
        plt.xlim(xlim_nm)        
        plt.ylim(ylim_kT)
        # add a second axis for kcal/mol
        ylim_kT = np.array(plt.ylim())
        ylim_kcal_mol = IWT_Util.kT_to_kcal_per_mol(ylim_kT)
        PlotUtilities.secondAxis(ax_free,label="kcal/mol",limits=ylim_kcal_mol,
                                 secondY =True)
        ax_tilt = plt.subplot(3,1,3)
        IWT_Plot.plot_tilted_landscape(LandscapeObj,fmt_f_label="{:.0f}",
                                       **kw_landscape) 
        PlotUtilities.xlabel("")
        plt.xlim(xlim_nm)       
        plt.ylim(ylim_kT)        
        # add another second axis for kcal/mol
        PlotUtilities.secondAxis(ax_tilt,label="kcal/mol",limits=ylim_kcal_mol,
                                 secondY =True)
        out_name= out_base + "IWT{:d}_{:.1g}.png".format(i,f*1e12)   
        PlotUtilities.savefig(fig,out_name)
开发者ID:prheenan,项目名称:Research,代码行数:100,代码来源:main_iwt_initial_br.py


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