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


Python PlotUtilities.zoom_effect01方法代码示例

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


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

示例1: rupture_plot

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

#.........这里部分代码省略.........
    index_absolute = index_after_event + slice_event_subplot.start
    rupture_time = x[index_absolute]
    # update all the slices
    slice_before_zoom = slice(zoom_start_idx,index_absolute)
    slice_after_zoom = slice(index_absolute,zoom_end_idx)
    slice_before_event = slice(0,index_absolute,1)
    slice_after_event = slice(index_absolute,None,1)
    x_zoom = x[slice_event_subplot]
    f_zoom = force[slice_event_subplot]
    ylim = [-30,max(force)*2]
    xlim = [0,1.3]
    xlim_zoom = [min(x_zoom),max(x_zoom)]
    ylim_zoom = [min(f_zoom),max(f_zoom)]
    # get the second zoom
    second_zoom = int(points_around/zoom_factor)
    zoom_second_before = slice(index_absolute-second_zoom,index_absolute)
    zoom_second_after  = slice(index_absolute,index_absolute+second_zoom)
    slice_second_zoom = slice(zoom_second_before.start,
                              zoom_second_after.stop)
    x_second_zoom = x[slice_second_zoom]
    force_second_zoom = force[slice_second_zoom]
    xlim_second_zoom = [min(x_second_zoom),max(x_second_zoom)]
    ylim_second_zoom = [min(force_second_zoom),max(force_second_zoom)]
    # plot everything
    n_rows = 3
    n_cols = 1
    fudge_y = 5
    ylabel = "Force (pN)"
    ax1 = plt.subplot(n_rows,n_cols,1)
    style_data = dict(alpha=0.5,linewidth=1)
    style_filtered = dict(alpha=1.0,linewidth=3)
    # plot the force etc
    Plotting.before_and_after(x,force,slice_before_event,slice_after_event,
                              style_data,label="Raw (25kHz)")
    Plotting.before_and_after(x,force_filtered,slice_before_event,
                              slice_after_event,style_filtered,
                              label="Filtered (25Hz)")
    legend_kwargs = dict(handlelength=1)
    PlotUtilities.lazyLabel("Time (s)",ylabel,"",loc="upper right",
                            frameon=False,legend_kwargs=legend_kwargs)
    plt.ylim(ylim)
    plt.xlim(xlim)
    ax1.xaxis.tick_top()
    ax1.xaxis.set_label_position('top') 
    marker_size=90
    Plotting.plot_arrows_above_events([index_absolute],x,force_filtered,
                                      fudge_y=fudge_y*4.5,
                                      markersize=marker_size)
    # plot the rupture
    # These are in unitless percentages of the figure size. (0,0 is bottom left)
    # zoom-factor: 2.5, location: upper-left
    ax2 = plt.subplot(n_rows,n_cols,2)
    style_data_post_zoom = dict(style_data)
    post_alpha = style_data['alpha']
    style_data_post_zoom['alpha']=post_alpha
    style_filtered_post_zoom = dict(style_filtered)
    style_filtered_post_zoom['alpha']=1
    Plotting.before_and_after(x,force,slice_before_zoom,slice_after_zoom,
                              style_data_post_zoom)
    plot_rupture = lambda l: Plotting.\
        plot_arrows_above_events([index_after_event],x_event_both,
                                 predicted_both,fudge_y=fudge_y,
                                 markersize=marker_size)
    plot_line = lambda l :  plt.plot(x_event_both[:index_after_event+1],
                                     predicted_both[:index_after_event+1],
                                     color='m',
                                     linestyle='-',linewidth=3,label=l)
    plot_rupture('Rupture')
    plot_line("Fit")
    PlotUtilities.lazyLabel("",ylabel,"",frameon=False,
                            loc='upper right',
                            legend_kwargs=dict(numpoints=1,**legend_kwargs))
    plt.xlim(xlim_zoom)
    plt.ylim(ylim_zoom)
    # make a scale bar for this plot
    scale_width = 0.01
    string = "{:d} ms".format(int(scale_width*1000))
    get_bar_location = lambda _xlim: np.mean([np.mean(_xlim),min(_xlim)])
    PlotUtilities.scale_bar_x(get_bar_location(xlim_zoom),
                              -12,s=string,width=scale_width)
    PlotUtilities.no_x_label()
    ax3 = plt.subplot(n_rows,n_cols,3)
    Plotting.before_and_after(x,force,zoom_second_before,zoom_second_after,
                              style_data_post_zoom)
    plt.xlim(xlim_second_zoom)
    plt.ylim(ylim_second_zoom)
    plot_rupture("")
    plot_line("")
    PlotUtilities.lazyLabel("",ylabel,"")
    # make a scale bar for this plot
    scale_width = scale_width/zoom_factor
    string = "{:.1f} ms".format(scale_width*1000)
    PlotUtilities.scale_bar_x(get_bar_location(xlim_second_zoom),
                              0,s=string,width=scale_width)
    PlotUtilities.no_x_label()
    # draw lines connecting the plots
    if (ax1_labels):
        PlotUtilities.zoom_effect01(ax1, ax2, *xlim_zoom)
    if (ax2_labels):
        PlotUtilities.zoom_effect01(ax2, ax3, *xlim_second_zoom)
开发者ID:prheenan,项目名称:Research,代码行数:104,代码来源:main_figure_rupture.py

示例2: plot

# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import zoom_effect01 [as 别名]
def plot(interp,split_fec,f,xlim_rel_start,xlim_rel_delta,
         when_to_break=_dont_break):
    # calculate all the things we will neeed
    time_sep_force = f(split_fec)
    x_plot,y_plot = Plotting.plot_format(time_sep_force)
    n_filter_points = 1000
    x_raw = time_sep_force.Time
    y_raw = time_sep_force.Force
    interp_raw = interp(x_raw)
    diff_raw = y_raw - interp_raw
    stdev = Analysis.local_stdev(diff_raw,n=split_fec.tau_num_points)
    xlims_rel = [ [i,i+xlim_rel_delta] for i in  xlim_rel_start]
    # convert to plotting units
    n = x_plot.size
    slices_abs = [ slice(int(i*n),int(f*n),1) for i,f in xlims_rel ]
    x_plot_slices = [ x_plot[s] for s in slices_abs ]
    diff_raw_slices = [diff_raw[s] for s in slices_abs]
    max_raw_diff_slices = [max(d) for d in diff_raw_slices]
    min_raw_diff_slices = [min(d) for d in diff_raw_slices]
    range_raw_diff_slices = np.array([min(min_raw_diff_slices),
                                      max(max_raw_diff_slices)])
    range_raw_diff = np.array([min(diff_raw),max(diff_raw)])
    range_plot_diff = f_plot_y(range_raw_diff*1.1)
    xlim_abs = [ [min(x),max(x)] for x in x_plot_slices]
    n_plots = len(x_plot_slices)
    # set up the plot styling
    style_approach = dict(color='b')
    style_raw = dict(alpha=0.3,**style_approach)
    style_interp = dict(linewidth=3,**style_approach)
    colors = ['r','m','k']
    style_regions = [] 
    for c in colors:
        style_tmp = dict(**style_raw)
        style_tmp['color'] = c
        style_regions.append(style_tmp)
    gs = gridspec.GridSpec(3,2*n_plots)
    plt.subplot(gs[0,:])
    plot_force(x_plot,y_plot,interp_raw,style_raw,style_interp)
    # highlight all the residual regions in their colors
    for style_tmp,slice_tmp in zip(style_regions,slices_abs):
        if (when_to_break == _break_after_interp):
            break
        style_interp_tmp = dict(**style_tmp)
        style_interp_tmp['alpha'] = 1
        plt.plot(x_plot[slice_tmp],y_plot[slice_tmp],**style_tmp)
        plt.plot(x_plot[slice_tmp],f_plot_y(interp_raw[slice_tmp]),linewidth=3,
                 **style_interp_tmp)
        if (when_to_break == _break_after_first_zoom):
            break
    ax_diff = plt.subplot(gs[1,:])
    plot_residual(x_plot,diff_raw,style_raw)
    # highlight all the residual regions in their colors
    for style_tmp,slice_tmp in zip(style_regions,slices_abs):
        if (when_to_break == _break_after_interp):
            break
        plt.plot(x_plot[slice_tmp],f_plot_y(diff_raw)[slice_tmp],**style_tmp)
        if (when_to_break == _break_after_first_zoom):
            break
    plt.ylim(range_plot_diff)
    tick_kwargs = dict(right=False)
    # plot all the subregions
    for i in range(n_plots):
        xlim_tmp = xlim_abs[i]
        ylim_tmp = range_plot_diff
        """
        plot the raw data
        """
        offset_idx = 2*i
        ax_tmp = plt.subplot(gs[-1,offset_idx])
        diff_tmp = diff_raw_slices[i]
        # convert everything to plotting units
        diff_plot_tmp =f_plot_y(diff_tmp) 
        x_plot_tmp = x_plot_slices[i]
        style_tmp = style_regions[i]
        if (when_to_break != _break_after_interp):
            plt.plot(x_plot_tmp,diff_plot_tmp,**style_tmp)
        PlotUtilities.no_x_anything()
        if (i != 0):
            PlotUtilities.no_y_label()
            PlotUtilities.tickAxisFont(**tick_kwargs)
        else:
            PlotUtilities.lazyLabel("","Force (pN)","",tick_kwargs=tick_kwargs)
        plt.xlim(xlim_tmp)
        plt.ylim(ylim_tmp)
        if (when_to_break != _break_after_interp):
            PlotUtilities.zoom_effect01(ax_diff, ax_tmp, *xlim_tmp)
        if (i == 0 and (when_to_break != _break_after_interp)):
            # make a scale bar for this plot
            time = 20e-3
            string = "{:d} ms".format(int(time*1000))
            PlotUtilities.scale_bar_x(np.mean(xlim_tmp),0.8*max(ylim_tmp),
                                      s=string,width=time,fontsize=15)
        """
        plot the histogram
        """
        ax_hist = plt.subplot(gs[-1,offset_idx+1])
        if (i == 0):
            PlotUtilities.xlabel("Count")
        else:
            PlotUtilities.no_x_label()
#.........这里部分代码省略.........
开发者ID:prheenan,项目名称:Research,代码行数:103,代码来源:main_figure_noise.py

示例3: run

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


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