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


Python PlotUtilities.save_png_and_svg方法代码示例

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


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

示例1: run

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

    Args:
        param1: This is the first param.
    
    Returns:
        This is a description of what is returned.
    """
    data_file = "../_Data/Scores.pkl"
    kw = dict(score_tx_func=get_only_nug2_ruptures)
    runs = [ ["./cache.pkl",dict(),"performance"],
             ["./cache_nug2.pkl",kw,"performance_nug2"]]
    PlotUtilities.tom_text_rendering()
    for cache_name,keywords,plot_name in runs:
        # get the metrics we care about
        metrics = CheckpointUtilities.getCheckpoint(cache_name,
                                                    Offline.get_best_metrics,
                                                    False,data_file,
                                                    **keywords)
        coeffs_compare = [m.coefficients() for m in metrics]
        write_coeffs_file("./coeffs.txt",coeffs_compare)
        # make the plot we want
        fig = PlotUtilities.figure(figsize=(7,3))
        make_metric_plot(metrics)
        axis_func = lambda axes: [ax for i,ax in enumerate(axes) if i < 3]
        loc_last_two = [-0.05,1.1]
        locs = [ [-0.2,1.1], loc_last_two,loc_last_two]
        PlotUtilities.label_tom(fig,axis_func=axis_func,loc=locs)
        # save out the plot
        subplots_adjust = dict(hspace=0.1,wspace=0.1,
                               bottom=0.125,top=0.93)
        PlotUtilities.save_png_and_svg(fig,plot_name,
                                       subplots_adjust=subplots_adjust)
开发者ID:prheenan,项目名称:Research,代码行数:37,代码来源:main_performance_figure.py

示例2: make_gallery_plot

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_png_and_svg [as 别名]
def make_gallery_plot(areas,data_to_analyze,out_name="./gallery"):
    # skip the first one (the entire landscape )
    helical_areas = areas[1:]
    helical_data = data_to_analyze[1:]
    helical_kwargs = landscape_kwargs()[1:]
    fig = PlotUtilities.figure((7,2.5))
    helical_gallery_plot(helical_areas,helical_data,helical_kwargs)    
    PlotUtilities.save_png_and_svg(fig,out_name)                    
开发者ID:prheenan,项目名称:Research,代码行数:10,代码来源:main_landscapes.py

示例3: make_detalied_plots

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_png_and_svg [as 别名]
def make_detalied_plots(data_to_analyze,areas):
    """
    makes the detailed plots
    """
    kwargs = landscape_kwargs()
    y_limits_pN = [None,None,125,100]
    for i,a in enumerate(areas):
        fig = PlotUtilities.figure((3.25,5))
        mdata = data_to_analyze[i]
        example = mdata.landscape[0]
        ax = create_landscape_plot(mdata,xlim=None,zero_q=False,**kwargs[i])
        ax_heat = ax[0]
        PlotUtilities.no_x_label(ax_heat)
        ax_heat.relim()
        ax_heat.set_ylim([None,y_limits_pN[i]])
        out_name = "landscape{:d}_{:s}".format(i,areas[i].plot_title)
        axis_func = lambda x: [x[0],x[2]]
        PlotUtilities.label_tom(fig,axis_func=axis_func)
        PlotUtilities.save_png_and_svg(fig,out_name.replace(" ","_"))    
开发者ID:prheenan,项目名称:Research,代码行数:21,代码来源:main_landscapes.py

示例4: run

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

#.........这里部分代码省略.........
    ax_final_prob = plt.subplot(gs[3,:])
    plt.plot(time_plot,to_prob_plot(info_final.cdf),
             **probability_kwargs)    
    title_consistent = (arrow + "Supress small force change events")
    PlotUtilities.lazyLabel("",probability_label_post,title_consistent,**kw)
    PlotUtilities.no_x_label(ax_final_prob)      
    plt.ylim(ylim_prob)    
    plt.xlim(xlim_time)
    Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final_prob,**prob_scale_dict)
    tick_style()
    # # plot the final event locations
    ax_final = plt.subplot(gs[4,:])
    plt.plot(time_plot,force_plot,**raw_force_kwargs)    
    plt.plot(time_plot,force_interp_plot,**interp_force_kwargs)
    PlotUtilities.no_x_label(ax_final)      
    title_final = (arrow + " Extract significant events")
    event_starts = [e.start for e in info_final.event_slices_raw]
    Plotting.plot_arrows_above_events(event_starts,plot_x=time_plot,
                                      plot_y=force_plot,fudge_y=40,
                                      label=None)
    PlotUtilities.lazyLabel("",force_label,title_final,
                            loc = "upper center",**kw)
    plt.ylim(ylim_force_pN)                           
    plt.xlim(xlim_time)
    Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final,**fec_scale_dict)
    tick_style()
    ylim_first_event = [-5,30]
    first_event_window_large = 0.045
    fraction_increase= 5
    color_first = 'm'
    # get the event index, window pct to use, where to show a 'zoom', and the
    # y limits (if none, just all of it)
    event_idx_fudge_and_kw = \
        [ [0 ,first_event_window_large   ,True,ylim_first_event,color_first],
          [0 ,first_event_window_large/fraction_increase,False,
           ylim_first_event,color_first],
          [-1,4e-3,True,[-50,None],'r']]
    widths_seconds = 1e-3 * np.array([50,10,5])
    for i,(event_id,fudge,zoom_bool,ylim,c) in \
        enumerate(event_idx_fudge_and_kw):
        # get how the interpolated plot should be 
        interp_force_kwargs_tmp = dict(**interp_force_kwargs)
        interp_force_kwargs_tmp['color'] = c
        interp_force_kwargs_tmp['linewidth'] = 1.25
        # determine the slice we want to use       
        event_location = info_final.event_idx[event_id]
        event_bounding_slice = slice_window_around(event_location,
                                                   time_plot,fraction=fudge)
        time_first_event_plot = time_plot[event_bounding_slice]
        time_slice = time_first_event_plot
        # # plot the interpolated on the *full plot* before we zoom in (so the
        # # colors match)
        plt.subplot(gs[-2,:])
        plt.plot(time_slice,force_interp_plot[event_bounding_slice],
                 **interp_force_kwargs_tmp)       
        plt.ylim(ylim_force_pN)
        # # next, plot the zoomed version
        in_ax = plt.subplot(gs[-1,i])
        in_ax.plot(time_slice,force_plot[event_bounding_slice],
                   **raw_force_kwargs)
        in_ax.plot(time_slice,force_interp_plot[event_bounding_slice],
                   **interp_force_kwargs_tmp)       
        PlotUtilities.no_x_anything(ax=in_ax)
        # removing  y label on all of them..
        if (i == 0):
            ylabel = force_label
        else:
            ylabel = ""
        # determine if we need to add in 'guidelines' for zooming
        if (zoom_bool):
            PlotUtilities.zoom_effect01(ax_final,in_ax,*in_ax.get_xlim(),
                                        color=c)
            PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
        else:
            # this is a 'second' zoom in...'
            PlotUtilities.no_y_label(in_ax)
            ylabel = ("{:d}x\n".format(fraction_increase)) + \
                      r"$\rightarrow$"
            PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
            PlotUtilities.ylabel(ylabel,rotation=0,labelpad=5)
        # plot an arrow over the (single) event
        Plotting.plot_arrows_above_events([event_location],plot_x=time_plot,
                                          plot_y=force_plot,fudge_y=7,
                                          label=None,markersize=150)
        plt.ylim(ylim)
        common = dict(unit="ms",
                      unit_kwargs=dict(value_function = lambda x: x*1e3))
        width = widths_seconds[i]
        Scalebar.x_scale_bar_and_ticks_relative(offset_y=0.1,offset_x=0.5,
                                                width=width,ax=in_ax,
                                                **common)
        PlotUtilities.tom_ticks(ax=in_ax,num_major=2,change_x=False)
    loc_major = [-0.15,1.2]
    loc_minor = [-0.15,1.15]
    locs = [loc_major for _ in range(5)] + \
           [loc_minor for _ in range(3)]
    PlotUtilities.label_tom(fig,loc=locs)
    subplots_adjust=dict(hspace=0.48,wspace=0.35)
    PlotUtilities.save_png_and_svg(fig,"flowchart",
                                   subplots_adjust=subplots_adjust)
开发者ID:prheenan,项目名称:Research,代码行数:104,代码来源:main_flowchart.py

示例5: make_pedagogical_plot

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_png_and_svg [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

示例6: run

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

#.........这里部分代码省略.........
        PlotUtilities.no_x_label(ax_tmp)
        PlotUtilities.x_label_on_top(ax_tmp)        
        PlotUtilities.lazyLabel("","","")        
        PlotUtilities.xlabel("Time")
    # read in the data ...
    base_re = "./recreation_figure_data/"
    # # Figure 1D from the science paper 
    ax_fec_ensemble = plt.subplot(top_spec[1,0])
    fig4d = figure_recreation.save_output(base_re,"Fig1D.csv")      
    ylim = [0,160]
    xlim = [18,32]
    for wlc_x,wlc_y in zip(fig4d.wlc_x,fig4d.wlc_y):
        plt.plot(wlc_x,wlc_y,'b--',alpha=0.4,linewidth=1,dashes=(2,2))
    for x,y in zip(fig4d.x,fig4d.y):
        plt.plot(x,y,alpha=1,linewidth=0.5)        
    ax_fec_ensemble.set_ylim(ylim)
    ax_fec_ensemble.set_xlim(xlim)    
    PlotUtilities.lazyLabel("Extension","Force","")        
    x_kwargs = dict(width=3,unit="nm")
    y_font = copy.deepcopy(Scalebar.def_font_kwargs_y)
    y_font['rotation'] = 90
    y_kwargs = dict(height=25,unit="pN",font_kwargs=y_font)
    Scalebar.crossed_x_and_y_relative(offset_x=0.22,offset_y=0.77,
                                      x_kwargs=x_kwargs,
                                      y_kwargs=y_kwargs,
                                      ax=ax_fec_ensemble)    
    PlotUtilities.no_x_label(ax=ax_fec_ensemble)                                      
    PlotUtilities.no_y_label(ax=ax_fec_ensemble)  
    # # Figure 4B from the science paper
    color_equil = 'rebeccapurple'
    fig4ab = figure_recreation.save_output(base_re,"Fig4AB.csv")  
    ax_time = plt.subplot(top_spec[1,1])
    min_x,max_x = min(fig4ab.time),max(fig4ab.time)
    range = [0.55,0.59]
    min_x_new = min_x + (max_x-min_x)*range[0]
    max_x_new = min_x + (max_x-min_x)*range[1]
    idx = np.where( (fig4ab.time <= max_x_new) & (fig4ab.time >= min_x_new))
    time = fig4ab.time[idx]
    force = fig4ab.force[idx]
    FEC_Plot._fec_base_plot(time,force,n_filter_points=200,
                            style_data=dict(color=color_equil,alpha=0.3,
                                            linewidth=0.75))
    ax_time.set_xlim(min_x_new,max_x_new)
    ax_time.set_ylim(None,None)
    unit_kwargs = dict(value_function =lambda x: x*1e6,fmt="{:.0f}")
    unit_micro_s = PlotUtilities.upright_mu() + "m"
    x_kwargs = dict(unit_kwargs=unit_kwargs,width=500e-6,unit=unit_micro_s)
    y_font = copy.deepcopy(Scalebar.def_font_kwargs_y)
    y_font['rotation'] = 90
    y_kwargs = dict(height=10,unit="pN",font_kwargs=y_font)
    Scalebar.crossed_x_and_y_relative(offset_x=0.5,offset_y=0.08,
                                      x_kwargs=x_kwargs,
                                      y_kwargs=y_kwargs,
                                      ax=ax_time)  
    PlotUtilities.no_x_label(ax=ax_time)                                      
    PlotUtilities.no_y_label(ax=ax_time)  
    PlotUtilities.lazyLabel("Time","Force","")
    velocity_annotate(ax=ax_time,v=0,color=color_equil)
    # # figure 4C from the science paper -- the pfold energy landscape 
    fig4c = figure_recreation.save_output(base_re,"Fig4C.csv")
    ax_equil = plt.subplot(top_spec[1,2])
    # data is in kJ/mol, communication with hao, 2017-9-14
    fig4c.energy /= 4.2
    fig4c.energy_error /= 4.2
    plt.errorbar(fig4c.x,fig4c.energy,fig4c.energy_error,color=color_equil,
                 marker='o',
                 mfc='w',zorder=0,markerfacecolor="None",capsize=2,elinewidth=1,
                 linewidth=1)                 
    PlotUtilities.lazyLabel("Extension (nm)","Energy","")     
    x_kwargs = dict(unit_kwargs=dict(fmt="{:.1f}"),width=0.1,unit="nm")
    y_font = copy.deepcopy(Scalebar.def_font_kwargs_y)
    y_font['rotation'] = 90
    y_kwargs = dict(unit_kwargs=dict(fmt="{:.1f}"),
                    height=0.5,unit="kcal/mol",font_kwargs=y_font)
    Scalebar.crossed_x_and_y_relative(offset_x=0.22,offset_y=0.60,
                                      x_kwargs=x_kwargs,
                                      y_kwargs=y_kwargs,
                                      ax=ax_equil)
    # add in bell...
    bell_mean = 0.64
    bell_std = 0.09
    x0,xf = ax_equil.get_xlim()
    mean_x = bell_mean * (xf-x0) + x0
    std_x = bell_std * (xf-x0)
    color_bell = 'k'
    plt.axvspan(mean_x-std_x,mean_x+std_x,color=color_bell,alpha=0.15)
    plt.axvline(mean_x,color=color_bell,linestyle='--',zorder=0,alpha=0.7)
    PlotUtilities.no_x_label(ax=ax_equil)         
    t = ax_equil.annotate(s=r"$\Delta x^{\ddag}_{\mathrm{Bell}}$",
                          xy=(0.4,0.3),color=color_bell,
                          xycoords="axes fraction")
    PlotUtilities.no_y_label(ax=ax_equil)    
    loc_upper = [-0.05,1.05]
    loc_lower = [-0.05,1.0]
    loc = [loc_upper,loc_upper,loc_upper,   
           loc_lower,loc_lower,loc_lower]
    PlotUtilities.label_tom(fig,loc=loc)
    subplots_adjust = dict(hspace=0.07,wspace=0.15)
    PlotUtilities.save_png_and_svg(fig,"diagram",
                                   subplots_adjust=subplots_adjust)
开发者ID:prheenan,项目名称:Research,代码行数:104,代码来源:main_diagram.py


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