本文整理汇总了Python中GeneralUtil.python.PlotUtilities.scale_bar_x方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.scale_bar_x方法的具体用法?Python PlotUtilities.scale_bar_x怎么用?Python PlotUtilities.scale_bar_x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.scale_bar_x方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import scale_bar_x [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()
#.........这里部分代码省略.........
示例2: rupture_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import scale_bar_x [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)