本文整理汇总了Python中GeneralUtil.python.PlotUtilities.unit_string方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.unit_string方法的具体用法?Python PlotUtilities.unit_string怎么用?Python PlotUtilities.unit_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.unit_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import unit_string [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,:])
#.........这里部分代码省略.........
示例2: plot_landscape
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import unit_string [as 别名]
def plot_landscape(data,xlim,kw_landscape=dict(),plot_derivative=True,
zero_q=True,
label_deltaG = PlotUtilities.variable_string("\Delta G")):
landscape_kcal_per_mol = data.mean_landscape_kcal_per_mol
landscape_kcal_per_mol -= min(landscape_kcal_per_mol)
std_landscape_kcal_per_mol = data.std_landscape_kcal_per_mol
extension_nm = data._extension_grid_nm
if (zero_q):
extension_nm -= min(extension_nm)
extension_aa = data.amino_acids_per_nm() * extension_nm
grad = lambda x: np.gradient(x)/(np.gradient(extension_aa))
delta_landscape_kcal_per_mol_per_amino_acid = grad(landscape_kcal_per_mol)
landscape_upper = landscape_kcal_per_mol+std_landscape_kcal_per_mol
landscape_lower =landscape_kcal_per_mol-std_landscape_kcal_per_mol
delta_landscape_kcal_per_mol_per_amino_acid = \
data.mean_delta_landscape_kcal_per_mol_per_AA
std_delta_landscape_kcal_per_mol_per_AA = \
data.std_delta_landscape_kcal_per_mol_per_AA
upper_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid+\
std_delta_landscape_kcal_per_mol_per_AA
lower_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid-\
std_delta_landscape_kcal_per_mol_per_AA
# make a second axis for the number of ammino acids
limits_delta = [min(delta_landscape_kcal_per_mol_per_amino_acid),
max(delta_landscape_kcal_per_mol_per_amino_acid)]
limits_energy = [min(landscape_kcal_per_mol),max(landscape_kcal_per_mol)]
units_energy_delta = label_deltaG + \
r" per AA (kcal/(mol $\cdot$ AA))"
units_energy = PlotUtilities.unit_string("\Delta G","kcal/mol")
difference_color = 'rebeccapurple'
landscape_color = kw_landscape['color']
if (plot_derivative):
PlotUtilities.lazyLabel("Extension (nm)",units_energy_delta,"")
PlotUtilities.ylabel(units_energy_delta,color=difference_color)
else:
PlotUtilities.lazyLabel("Extension (nm)","","")
PlotUtilities.ylabel(units_energy,color=landscape_color)
# the derivative goes on the main axis in this case...
if (plot_derivative):
ax_delta = plt.gca()
ax_2 = PlotUtilities.secondAxis(ax_delta,
label=units_energy,color=landscape_color,
limits=limits_energy,secondY =True,
tick_color=landscape_color)
ax_energy = ax_2
to_ret = ax_delta,ax_energy
else:
ax_energy = plt.gca()
ax_delta = None
to_ret = ax_energy
# filter the data if we need to
if (xlim is not None and xlim[1] is not None):
idx= np.where( (extension_nm > xlim[0]) & (extension_nm < xlim[1]))
else:
idx =np.arange(extension_nm.size)
# plot the landscape and its standard deviation
ax_energy.plot(extension_nm[idx],landscape_kcal_per_mol[idx],
label=label_deltaG,zorder=10,**kw_landscape)
ax_energy.fill_between(x=extension_nm[idx],
y1=landscape_lower[idx],
y2=landscape_upper[idx],
alpha=0.15,zorder=10,**kw_landscape)
# the energy y label should be rotated if it is on the right
rotation = -90
if plot_derivative:
kw_y = dict(rotation=-90,x=-0.3)
else:
kw_y = dict()
PlotUtilities.ylabel(ax=ax_energy,lab=units_energy,**kw_y)
# move the y label to the right slightly i we are using both axes
if plot_derivative:
ax_energy.yaxis.set_label_coords(1.2,0.5)
if (plot_derivative):
# plot the energy delta and its bounds, based on the bounds on the
# landscape
ax_delta.plot(extension_nm[idx],
delta_landscape_kcal_per_mol_per_amino_acid[idx],
color=difference_color,linestyle='-',linewidth=1.5)
PlotUtilities.color_axis_ticks(color=landscape_color,ax=ax_energy,
spine_name='right')
ax_delta.fill_between(x=extension_nm[idx],
y1=lower_delta_landscape[idx],
y2=upper_delta_landscape[idx],
alpha=0.15,color=difference_color)
return to_ret