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


Python PlotUtilities.no_y_anything方法代码示例

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


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

示例1: zoomed_axis

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_anything [as 别名]
def zoomed_axis(ax=plt.gca(),xlim=[None,None],ylim=[None,None],
                remove_ticks=True,zoom=1,borderpad=1,loc=4,**kw):
    """
    Creates a (pretty) zoomed axis
    
    Args:
        ax: which axis to zoom on
        <x/y>_lim: the axes limits
        remove_ticks: if true, removes the x and y ticks, to reduce clutter
        remaining args: passed to zoomed_inset_axes
    Returns:
        the inset axis
    """    
    axins = zoomed_inset_axes(ax, zoom=zoom, loc=loc,borderpad=borderpad)
    axins.set_xlim(*xlim) # apply the x-limits
    axins.set_ylim(*ylim) # apply the y-limits
    if (remove_ticks):
        PlotUtilities.no_x_anything(axins)
        PlotUtilities.no_y_anything(axins)
    return axins
开发者ID:prheenan,项目名称:GeneralUtil,代码行数:22,代码来源:Inset.py

示例2: make_pedagogical_plot

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_anything [as 别名]
def make_pedagogical_plot(data_to_plot,kw,out_name="./iwt_diagram"):
    heatmap_data = data_to_plot.heatmap_data
    data = landscape_data(data_to_plot.landscape)
    fig = PlotUtilities.figure((3.25,5))
    # # ploy the heat map 
    ax_heat = plt.subplot(3,1,1)
    heatmap_plot(heatmap_data,data.amino_acids_per_nm(),
                 kw_heatmap=kw['kw_heatmap'])
    xlim_fec = plt.xlim()
    PlotUtilities.no_x_label(ax_heat)    
    ax_heat.set_ylim([0,150])
    PlotUtilities.no_x_label(ax_heat)
    PlotUtilities.no_y_label(ax_heat)   
    fontsize_scalebar = 6 
    common_kw = dict(color='w',fontsize=fontsize_scalebar)
    x_font,y_font = Scalebar.\
        font_kwargs_modified(x_kwargs=common_kw,
                             y_kwargs=common_kw)
    heat_kw_common = dict(line_kwargs=dict(color='w',linewidth=1.5))
    x_heat_kw = dict(width=15,unit="nm",font_kwargs=x_font,**heat_kw_common)
    y_heat_kw = dict(height=30,unit='pN ',font_kwargs=y_font,**heat_kw_common)
    # add a scale bar for the heatmap...
    scale_bar_x = 0.83
    Scalebar.crossed_x_and_y_relative(scale_bar_x,0.55,ax=ax_heat,
                                      x_kwargs=x_heat_kw,
                                      y_kwargs=y_heat_kw)
    jcp_fig_util.add_helical_boxes(ax=ax_heat,ymax_box=0.9,alpha=1.0,
                                   font_color='w',offset_bool=True)
    # # plot the energy landscape...
    ax_correction = plt.subplot(3,1,2)    
    plot_with_corrections(data)
    PlotUtilities.no_x_label(ax_correction)
    PlotUtilities.lazyLabel("","Energy (kcal/mol)","")
    ax_correction.set_xlim(xlim_fec)            
    offset_y_pedagogy = 0.42
    setup_pedagogy_ticks(ax_correction,scale_bar_x,x_heat_kw,y_heat_kw,
                         offset_y=offset_y_pedagogy)
    legend_font_size = 9                         
    legend = PlotUtilities.legend(handlelength=1.5,loc=(0.15,0.07),ncol=3,
                                  fontsize=legend_font_size,handletextpad=0.4)
    for i,text in enumerate(legend.get_texts()):
        plt.setp(text, color = kwargs_correction()[i]['color'])    
    # make the inset plot 
    axins = zoomed_inset_axes(ax_correction, zoom=3, loc=2,
                              borderpad=0.8) 
    plot_with_corrections(data)
    xlim_box = [1,5]
    ylim_box = [-3,28]
    plt.xlim(xlim_box)
    plt.ylim(ylim_box)
    PlotUtilities.no_x_anything(axins)
    PlotUtilities.no_y_anything(axins)
    # add in scale bars
    kw_common = dict(line_kwargs=dict(linewidth=0.75,color='k'))
    common_font_inset = dict(fontsize=fontsize_scalebar)
    x_kwargs = dict(verticalalignment='top',**common_font_inset)
    x_font,y_font = Scalebar.\
        font_kwargs_modified(x_kwargs=x_kwargs,
                             y_kwargs=dict(horizontalalignment='right',
                                           **common_font_inset))
    # set up the font, offset ('fudge') the text from the lines                              
    fudge_x = dict(x=0,y=-0.5)
    fudge_y = dict(x=0,y=0.1)
    Scalebar.crossed_x_and_y_relative(0.55,0.66,ax=axins,
                                      x_kwargs=dict(width=2,unit="nm",
                                                    font_kwargs=x_font,
                                                    fudge_text_pct=fudge_x,
                                                    **kw_common),
                                      y_kwargs=dict(height=8,unit='kcal/\nmol',
                                                    font_kwargs=y_font,
                                                    fudge_text_pct=fudge_y,                                                    
                                                    **kw_common))
    # draw a bbox of the region of the inset axes in the parent axes and
    # connecting lines between the bbox and the inset axes area
    color_box = 'rebeccapurple'           
    PlotUtilities.color_frame('rebeccapurple',ax=axins) 
    Annotations.add_rectangle(ax_correction,xlim_box,ylim_box,edgecolor=color_box)
    ax_correction.set_xlim(xlim_fec)
    ax_energy = plt.subplot(3,1,3)    
    plot_landscape(data,xlim_fec,kw_landscape=kw['kw_landscape'],
                   plot_derivative=False,label_deltaG=" ")
    ax_energy.set_xlim(xlim_fec)                         
    setup_pedagogy_ticks(ax_energy,scale_bar_x,x_heat_kw,y_heat_kw,
                         offset_y=offset_y_pedagogy)
    # add in the equation notation
    strings,colors = [],[]
    labels = kwargs_labels()
    # add in the appropriate symbols 
    strings = ["$\Delta G$ = ",labels[0]," + ",labels[1]," - ",labels[2]]
    colors_labels = [c['color'] for c in kwargs_correction()]
    colors = ["k"] + [item for list in [[c,"k"] for c in colors_labels]
                      for item in list]
    x,y = Scalebar.x_and_y_to_abs(x_rel=0.08,y_rel=0.85,ax=ax_energy)        
    Annotations.rainbow_text(x,y,strings=strings,colors=colors,
                             ax=ax_energy,size=legend_font_size)
    PlotUtilities.legend(handlelength=0.5,loc=(0.03,0.8))                             
    PlotUtilities.no_x_label(ax_energy)                         
    PlotUtilities.save_png_and_svg(fig,out_name)  
开发者ID:prheenan,项目名称:Research,代码行数:100,代码来源:main_landscapes.py

示例3: run

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_anything [as 别名]
def run():
    """
    """
    landscape = CheckpointUtilities.lazy_load("./example_landscape.pkl")
    # make the landscape relative
    landscape.offset_energy(min(landscape.G_0))
    landscape.offset_extension(min(landscape.q))
    # get the landscape, A_z in kT. Note that we convert z->q, so it is
    # really A(q=z-A'/k)
    A_q = landscape.A_z
    A_q_kT = (A_q * landscape.beta)
    # numerically differentiate
    to_y = lambda x: x * 1e12
    landscape_deriv_plot = to_y(np.gradient(A_q)/np.gradient(landscape.q))
    # compare with the A' term. XXX should just save it...
    weighted_deriv_plot = to_y(landscape.A_z_dot)
    x_plot = landscape.q * 1e9
    label_A_q_dot = r"$\dot{A}$"
    label_finite = label_A_q_dot + r" from finite difference"
    label_work = r"{:s}$ =<<F>>$".format(label_A_q_dot)
    kw_weighted = dict(color='m',label=label_work)
    fig = PlotUtilities.figure((3.5,5))
    # # plot just A(q)
    ax_A_q = plt.subplot(3,1,1)
    plt.plot(x_plot,A_q_kT,color='c',label="$A$")
    PlotUtilities.lazyLabel("","Helmholtz A ($k_\mathrm{b}T$)","",
                            loc=(0.5,0.8),frameon=True)
    PlotUtilities.set_legend_kwargs(ax=ax_A_q,background_color='w',linewidth=0)
    PlotUtilities.no_x_label(ax_A_q)
    x0 = 14.5
    dx = 0.05
    xlim = [x0,x0+dx]
    # plot the data red where we will zoom in 
    where_region = np.where( (x_plot >= xlim[0]) & 
                             (x_plot <= xlim[1]))
    zoom_x = x_plot[where_region]
    zoom_y = A_q_kT[where_region]
    ylim = [min(zoom_y),max(zoom_y)]
    dy = ylim[1]-ylim[0]
    # add in some extra space for the scalebar 
    ylim_fudge = 0.7
    ylim = [ylim[0],ylim[1] + (ylim_fudge * dy)]
    lazy_common = dict(title_kwargs=dict(loc='left'))
    plt.axvspan(*xlim,color='r',alpha=0.3,edgecolor="None")
    plt.plot(zoom_x,zoom_y,color='r')
    # plot a zoomed in axis, to clarify why it probably goes wrong 
    axins = zoomed_inset_axes(ax_A_q, zoom=250, loc=4,borderpad=1)
    axins.plot(x_plot, A_q_kT,linewidth=0.1,color='r')
    axins.set_xlim(*xlim) # apply the x-limits
    axins.set_ylim(*ylim) # apply the y-limits
    PlotUtilities.no_x_anything(axins)
    PlotUtilities.no_y_anything(axins)
    # add in a scale bar for the inset
    unit_kw_x = dict(fmt="{:.0f}",value_function=lambda x: x*1000)
    common = dict(line_kwargs=dict(linewidth=1.0,color='k'))
    # round to ~10s of pm
    x_width = np.around(dx/3,2)
    y_width = np.around(dy/3,1)
    x_kw = dict(width=x_width,unit="pm",unit_kwargs=unit_kw_x,
                fudge_text_pct=dict(x=0.2,y=-0.2),**common)
    y_kw = dict(height=y_width,unit=r"$k_\mathrm{b}T$",
                unit_kwargs=dict(fmt="{:.1f}"),**common)
    Scalebar.crossed_x_and_y_relative(ax=axins,
                                      offset_x=0.45,
                                      offset_y=0.7,
                                      x_kwargs=x_kw,
                                      y_kwargs=y_kw)
    # # plot A_z_dot 
    ax_deriv_both = plt.subplot(3,1,2)
    # divide by 1000 to get uN
    plt.plot(x_plot,landscape_deriv_plot/1e6,color='k',
             label=label_finite)
    plt.plot(x_plot,weighted_deriv_plot/1e6,**kw_weighted)
    PlotUtilities.lazyLabel("",
                            "$\dot{A}(q)$ ($\mathrm{\mu}$N)",
                            "$\Downarrow$ Determine derivative (both methods)",
                            **lazy_common)
    PlotUtilities.no_x_label(ax_deriv_both)
    # # plot A_z_dot, but just the weighted method (ie: not super wacky)
    ax_deriv_weighted = plt.subplot(3,1,3)
    plt.plot(x_plot,weighted_deriv_plot,linewidth=1,**kw_weighted)
    title_last = "$\Downarrow$ Work-weighted method is reasonable "
    PlotUtilities.lazyLabel("Extension (nm)","$\dot{A}(q)$ (pN)",
                            title_last,**lazy_common)
    PlotUtilities.savefig(fig,"./finite_differences.png",
                          subplots_adjust=dict(hspace=0.2))
开发者ID:prheenan,项目名称:Research,代码行数:88,代码来源:main_finite_difference.py


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