本文整理汇总了Python中GeneralUtil.python.PlotUtilities.x_label_on_top方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.x_label_on_top方法的具体用法?Python PlotUtilities.x_label_on_top怎么用?Python PlotUtilities.x_label_on_top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.x_label_on_top方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import x_label_on_top [as 别名]
def make_plot(retract,pred_info,event,interp_raw,probability_idx,
surface_idx,use_previous=True,use_surface_shading=True):
# get the plotting information
style_raw = dict(color='k',alpha=0.3)
style_interp = dict(color='k',alpha=1)
x_plot,y_plot = Plotting.plot_format(retract)
min_x,max_x = min(x_plot),max(x_plot)/3
fudge_x = abs(max_x-min_x) * 0.05
xlim = np.array([min_x-fudge_x,max_x+fudge_x])
probabilities = pred_info.probabilities
probability_min = np.min([min(p) for p in probabilities])
before_slice = event
after_slice = slice(event.stop,None,1)
surface_plot = lambda label : \
plt.axvspan(min(x_plot),x_plot[surface_idx],alpha=0.2,color='k',
label=label)
color_plot = lambda x,y,**kw : \
Plotting.before_and_after(x,y,before_slice,after_slice,**kw)
plt.subplot(2,1,1)
color_plot(x_plot,y_plot,style=dict(alpha=0.3))
color_plot(x_plot,f_plot_y(interp_raw))
if (use_surface_shading):
surface_plot(None)
PlotUtilities.x_label_on_top()
PlotUtilities.lazyLabel("Time (s)","Force (pN)","")
plt.xlim(xlim)
plt.subplot(2,1,2)
if (use_previous and (probability_idx != 0)):
plt.semilogy(x_plot,probabilities[probability_idx-1],color='k',
alpha=0.3,linestyle='--',label="Previous")
plt.semilogy(x_plot,probabilities[probability_idx],label="Probability",
color='k')
plt.xlim(xlim)
plt.ylim([probability_min/2,2])
if (use_surface_shading):
surface_plot("Surface")
PlotUtilities.no_x_label()
PlotUtilities.lazyLabel("","Probability","",loc="lower right")
示例2: plot_force
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import x_label_on_top [as 别名]
def plot_force(x_plot,y_plot,interp_raw,style_raw,style_interp):
plt.plot(x_plot,y_plot,**style_raw)
plt.plot(x_plot,f_plot_y(interp_raw),**style_interp)
PlotUtilities.lazyLabel("Time (s)","Force (pN)","")
PlotUtilities.x_label_on_top()
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import x_label_on_top [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
data_file = "../_Data/example_protein.pkl"
data = CheckpointUtilities.lazy_load(data_file)
# get the 'raw' no-event probabilities, and the increasingly domain-specific
# ones
threshold = 1e-3
pred_kw = dict(threshold=threshold)
split_fec_no_domain_specific,info_no_domain_specific= \
Detector._predict_full(data,f_refs=[],**pred_kw)
_,info_remove_adhesions = Detector._predict_full(data,\
f_refs=[Detector.adhesion_mask_function_for_split_fec],**pred_kw)
_,info_final = Detector._predict_full(data,**pred_kw)
# get the plotting versions of the time, etc
time= split_fec_no_domain_specific.retract.Time
time_plot = time - time[0]
final_event_time = time_plot[info_final.event_idx[-1]]
xlim_time = [0,final_event_time*1.1]
force_plot = split_fec_no_domain_specific.retract.Force * 1e12
force_interp_plot = \
split_fec_no_domain_specific.retract_spline_interpolator()(time) * 1e12
# plot everything
raw_force_kwargs = dict(color='k',alpha=0.3)
interp_force_kwargs = dict(color='b',linewidth=1.25)
probability_kwargs = dict(color='r',linestyle="-",linewidth=0.75)
# for the probabilities, how far from the maximum y the scale bar should be
# (units [0,1]
y_frac_prob = 0.3
common_scale_dict = dict(width=0.1,unit="ms",
unit_kwargs=dict(value_function=lambda x: 1e3 * x))
fec_scale_dict = dict(offset_y=0.5,offset_x=0.15,**common_scale_dict)
prob_scale_dict = dict(**fec_scale_dict)
prob_scale_dict['offset_y'] = y_frac_prob
n_cols = 1
n_rows = 6
ylim_force_pN = [-35,max(force_interp_plot)+1.1+75]
to_prob_plot = lambda x: np.log10(x)
ylim_prob = [to_prob_plot(min((info_final.cdf))/5),1.1]
title_kwargs = dict(loc='left',color='b')
kwargs_axis = dict()
kw = dict(title_kwargs=title_kwargs,axis_kwargs=kwargs_axis)
arrow = "$\Downarrow$"
prob_str = PlotUtilities.variable_string("P")
force_str = PlotUtilities.unit_string("F")
probability_label = "log$_{\mathbf{10}}$" + "({:s})".format(prob_str)
probability_label_post = probability_label
n_cols = 3
n_rows = 6
force_label = "{:s} (pN)".format(force_str)
gs = gridspec.GridSpec(nrows=n_rows,ncols=n_cols,
width_ratios=[1 for _ in range(n_cols)],
height_ratios=[0.75,0.75,0.75,0.75,1,1])
fig = PlotUtilities.figure(figsize=(3.25,4.25))
# plot the 'raw' force and spline
ax_raw = plt.subplot(gs[0,:])
plt.plot(time_plot,force_plot,label="Raw",**raw_force_kwargs)
plt.plot(time_plot,force_interp_plot,label="Spline",
**interp_force_kwargs)
PlotUtilities.x_label_on_top(ax_raw)
PlotUtilities.no_x_label(ax_raw)
plt.ylim(ylim_force_pN)
PlotUtilities.lazyLabel("Time (s)",force_label,"",loc="upper center",
legend_kwargs=dict(handlelength=0.75,ncol=2),
**kw)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_raw,**fec_scale_dict)
tick_style()
# # plot the 'raw' probability
ax_raw_prob = plt.subplot(gs[1,:])
plt.plot(time_plot,to_prob_plot(info_no_domain_specific.cdf),
**probability_kwargs)
title_prob = arrow + "Determine probability of no event"
PlotUtilities.lazyLabel("",probability_label,title_prob,**kw)
PlotUtilities.no_x_label(ax_raw_prob)
plt.ylim(ylim_prob)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_raw_prob,**prob_scale_dict)
tick_style()
# # plot the adhesion-fixed probability
ax_adhesion = plt.subplot(gs[2,:])
plt.plot(time_plot,to_prob_plot(info_remove_adhesions.cdf),
**probability_kwargs)
title_adhesion = arrow + r"Suppress adhesion, stretching"
PlotUtilities.lazyLabel("",probability_label_post,title_adhesion,**kw)
PlotUtilities.no_x_label(ax_adhesion)
plt.ylim(ylim_prob)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_adhesion,
**prob_scale_dict)
tick_style()
# # plot the final probability
ax_final_prob = plt.subplot(gs[3,:])
#.........这里部分代码省略.........
示例4: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import x_label_on_top [as 别名]
def run():
"""
<Description>q
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
in_dir = None
flickering_dir = "../Data/fec/"
# XXX use the flickering dir for stuff
cache_dir = flickering_dir
GenUtilities.ensureDirExists(flickering_dir)
force_read_data = False
raw_data = IoUtilHao.read_and_cache_data_hao(flickering_dir,
force=force_read_data,
cache_directory=flickering_dir,
limit=3)
example = raw_data[0]
example_plot = copy.deepcopy(example)
# fix the manual offset
example_plot.LowResData.force -= 7.1
plot_examples = [example_plot]
vel_m_per_s = example_plot.Velocity
x_func = lambda y: y.Separation
y_func = lambda y: y.Force
ylim_pN = [-20,155]
xlim_nm = [5,75]
zoom_regions_nm = [ [61.5,63.6]]
adhesion_max_nm = 19
region_labels = ["ED Helix","CB Helix","A Helix"]
region_colors = jcp_fig_util.regions_and_colors()
regions_nm = [[x,l,c] for l,(x,c) in zip(region_labels,region_colors)]
colors_regions = [regions_nm[-1]]
# slice the regions
regions = [FEC_Util.slice_by_separation(example_plot,*reg)
for reg in zoom_regions_nm]
ylim_pN_zoom = [50,120]
# # make the plot
fig = PlotUtilities.figure((7,4))
# create the 'top' gridspec
top_spec = gridspec.GridSpec(2,3)
# create separate axes for the image and FECs
image_spec = \
gridspec.GridSpecFromSubplotSpec(1,1,subplot_spec=top_spec[0,0])
data_spec = \
gridspec.GridSpecFromSubplotSpec(1,2,subplot_spec=top_spec[0,1:])
# # plot the image
ax = plt.subplot(image_spec[:])
plt.imshow(plt.imread("../Data/sample_cartoon.png"),aspect='auto')
ax.axis('off')
# # plot the example fec and zoomed regions
#
# 'full' example
ax_example = plt.subplot(data_spec[:,0])
alpha_data = 0.4
color_data = 'g'
dict_plot = dict(n_filter_points=2000,
style_data=dict(color=color_data,alpha=alpha_data,
linewidth=0.5,linestyle='-'))
x_full_plot = x_func(example_plot)
FEC_Plot._fec_base_plot(x_full_plot,y_func(example_plot),
**dict_plot)
PlotUtilities.tom_ticks(ax=ax_example,num_major=5,change_x=False)
PlotUtilities.tom_ticks(ax=ax_example,num_major=4,change_y=False)
for i,(r,color) in enumerate(zip(regions,colors_regions)):
# put a box around the region
x,y = x_func(r),y_func(r)
Annotations.add_rectangle(ax_example,[min(x),max(x)],[min(y),max(y)])
plt.ylim(ylim_pN)
plt.xlim(xlim_nm)
jcp_fig_util.add_helical_boxes(ax=ax_example)
# plot the adhesion regions
plt.axvspan(min(x_full_plot),adhesion_max_nm,color='0.85',
linewidth=0)
PlotUtilities.lazyLabel("Extension","Force","")
PlotUtilities.x_label_on_top(ax_example)
PlotUtilities.no_x_label(ax_example)
PlotUtilities.no_y_label(ax_example)
x_kwargs = dict(unit_kwargs=dict(fmt="{:.0f}"),width=15,unit="nm")
y_kwargs = dict(unit_kwargs=dict(fmt="{:.0f}"),
height=40,unit="pN")
Scalebar.crossed_x_and_y_relative(offset_x=0.55,offset_y=0.58,
x_kwargs=x_kwargs,
y_kwargs=y_kwargs,
ax=ax_example)
# add in the velocity annotation (in nm/s, from m/s)
velocity_annotate(ax=ax_example,v=vel_m_per_s*1e9)
# # plot all the zoomed regions
offsets_x = [0.8]
offsets_y = [0.67]
heights_pN = [10]
widths_s = [0.001]
for i,(r,color) in enumerate(zip(regions,colors_regions)):
ax_tmp = plt.subplot(data_spec[-1])
dict_tmp = dict(**dict_plot)
dict_tmp['style_data']['color'] = color[-1]
time = r.Time
#.........这里部分代码省略.........