本文整理汇总了Python中GeneralUtil.python.PlotUtilities.xlabel方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.xlabel方法的具体用法?Python PlotUtilities.xlabel怎么用?Python PlotUtilities.xlabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.xlabel方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
Base = "./"
OutBase = Base + "out/"
InFiles = [Base + "PatrickIsGreedy.pxp"]
RawData = IWT_Util.\
ReadInAllFiles(InFiles,Limit=50,
ValidFunc=PxpLoader.valid_fec_allow_endings)
# get the start/ends of the re-folding and unfolding portions
# hard coded constant for now...
# XXX for re-folding, need to add in schedule
# XXX ensure properly zeroed?
idx_end_of_unfolding = int(16100/2)
IwtData,IwtData_fold = split(RawData,idx_end_of_unfolding)
# get the titled landscape...
all_landscape = [-np.inf,np.inf]
Bounds = IWT_Util.BoundsObj(bounds_folded_nm= all_landscape,
bounds_transition_nm= all_landscape,
bounds_unfolded_nm=all_landscape,
force_one_half_N=15e-12)
OutBase = "./out/"
# get the unfolding histograms
forces_unfold = np.concatenate([r.Force for r in IwtData])
separations_unfold = np.concatenate([r.Extension for r in IwtData])
# get the folding histograms..
forces_fold = np.concatenate([r.Force for r in IwtData_fold])
separations_fold = np.concatenate([r.Extension for r in IwtData_fold])
# zero everything...
n_bins = 80
fig = PlotUtilities.figure(figsize=(12,16))
kwargs_histogram = dict(AddAverage=False,nBins=n_bins)
plt.subplot(2,1,1)
IWT_Util.ForceExtensionHistograms(separations_unfold*1e9,
forces_unfold*1e12,**kwargs_histogram)
PlotUtilities.xlabel("")
PlotUtilities.title("*Unfolding* 2-D histogram")
plt.subplot(2,1,2)
IWT_Util.ForceExtensionHistograms(separations_fold*1e9,
forces_fold*1e12,**kwargs_histogram)
PlotUtilities.title("*Folding* 2-D histogram")
PlotUtilities.savefig(fig,OutBase + "0_{:d}hist.pdf".format(n_bins))
IWT_Plot.InTheWeedsPlot(OutBase=OutBase,
UnfoldObj=IwtData,
bounds=Bounds,Bins=[40,60,80,120,200],
max_landscape_kT=None,
min_landscape_kT=None)
示例2: plot_fec_cartoon
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def plot_fec_cartoon(base,data_base,file_names,arrow_kwargs=dict()):
kw = dict(cache_directory=data_base,force=False)
file_paths = [data_base + f +".csv" for f in file_names]
cases = [read_and_cache_file(f,**kw) for f in file_paths]
n_cases = len(cases)
out_names = []
event_styles = Plotting._fec_event_colors
styles = [dict(colors=event_styles,use_events=False),
dict(colors=event_styles),
dict(colors=event_styles)]
fudge_pN = [10,12,25]
im_path = base + "/cartoon/SurfaceChemistry Dig10p3_pmod-0{:d}.png"
gs= gridspec.GridSpec(2,3)
for i in range(3):
plt.subplot(gs[0, i])
image = plt.imread(im_path.format(i+1))
plt.imshow(image,interpolation="bilinear",aspect='equal',extent=None)
ax = plt.gca()
ax.axis('off')
for i,c in enumerate(cases):
plt.subplot(gs[1, i])
style = styles[i]
fec_split = Plotting.plot_fec(c,**style)
plt.xlim([-30,650])
# decorate the plot to make it easier to read
plot_x = fec_split.retract.Separation * 1e9
plot_y = fec_split.retract.Force *1e12
slices = fec_split.get_retract_event_slices()
Plotting.top_bars(plot_x,plot_x,slices,colors=style['colors'])
event_idx = [slice_v.stop for slice_v in slices]
if (len(event_idx) > 0):
# remove the last index (just te end of the FEC)
event_idx = event_idx[:-1]
fudge =fudge_pN[i]
Plotting.plot_arrows_above_events(event_idx,plot_x,plot_y,fudge,
**arrow_kwargs)
not_first_plot = i != 0
fmt(remove_y_labels=False,remove_x_labels=False)
if (i == 0):
y_label = r"Force (pN)"
x_label = "Separation (nm)"
else:
y_label = ""
x_label = ""
ax = plt.gca()
PlotUtilities.no_y_label(ax=ax)
PlotUtilities.ylabel(y_label)
PlotUtilities.xlabel(x_label)
PlotUtilities.tick_axis_number(num_x_major=4)
示例3: plot_single_landscape
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def plot_single_landscape(LandscapeObj,**kwargs):
"""
Plots a detailed energy landscape, and saves
Args:
LandscapeObj: energy landscape object (untilted)
**kwargs: passed to plot_tilted_landscape
Returns:
second, kcal/mol axis of tilted landscape
"""
plt.subplot(2,1,1)
plot_free_landscape(LandscapeObj,**kwargs)
plt.subplot(2,1,2)
to_ret = plot_tilted_landscape(LandscapeObj,**kwargs)
PlotUtilities.xlabel("Extension (nm)")
return to_ret
示例4: make_energy_landscape_plots
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def make_energy_landscape_plots(out_dir,energy_landscape_unfolding):
limits_kT = [-2,15]
landscape_zeroed = copy.deepcopy(energy_landscape_unfolding)
landscape_zeroed.Extensions -= min(landscape_zeroed.Extensions)
# plot the iwt transform as just a free landscape
fig = PlotUtilities.figure()
IWT_Plot.plot_free_landscape(landscape_zeroed)
PlotUtilities.xlabel("Separation (nm)")
PlotUtilities.savefig(fig,out_dir + "free_landscape.png")
# plot the tileted landscape
f_one_half_N_arr = np.array([7,8.5,10,12,13,15])*1e-12
for i,tilt_N in enumerate(f_one_half_N_arr):
fig = PlotUtilities.figure()
IWT_Plot.plot_tilted_landscape(landscape_zeroed,f_one_half_N=tilt_N)
PlotUtilities.xlabel("Separation (nm)")
save_name = "{:s}free_landscape_tilted_{:d}_{:.2g}.png".\
format(out_dir,i,tilt_N*1e12)
PlotUtilities.savefig(fig,save_name)
示例5: helical_gallery_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def helical_gallery_plot(helical_areas,helical_data,helical_kwargs):
axs,first_axs,second_axs = [],[],[]
offset_y = 0.2
kw_scalebars = [dict(offset_x=0.35,offset_y=offset_y),
dict(offset_x=0.35,offset_y=offset_y),
dict(offset_x=0.35,offset_y=offset_y)]
xlims = [ [None,None],[None,None],[None,15] ]
arrow_x = [0.60,0.62,0.55]
arrow_y = [0.58,0.60,0.45]
for i,a in enumerate(helical_areas):
data = helical_data[i]
kw_tmp = helical_kwargs[i]
data_landscape = landscape_data(data.landscape)
# # plot the energy landscape...
ax_tmp = plt.subplot(1,len(helical_areas),(i+1))
axs.append(ax_tmp)
kw_landscape = kw_tmp['kw_landscape']
color = kw_landscape['color']
ax_1, ax_2 = plot_landscape(data_landscape,xlim=xlims[i],
kw_landscape=kw_landscape,
plot_derivative=True)
first_axs.append(ax_1)
second_axs.append(ax_2)
PlotUtilities.tom_ticks(ax=ax_2,num_major=5,change_x=False)
last_idx = len(helical_areas)-1
ax_1.annotate("",xytext=(arrow_x[i],arrow_y[i]),textcoords='axes fraction',
xy=(arrow_x[i]+0.2,arrow_y[i]),xycoords='axes fraction',
arrowprops=dict(facecolor=color,alpha=0.7,
edgecolor="None",width=4,headwidth=10,
headlength=5))
if (i > 0):
PlotUtilities.ylabel("")
PlotUtilities.xlabel("")
if (i != last_idx):
ax_2.set_ylabel("")
PlotUtilities.no_x_label(ax_1)
PlotUtilities.no_x_label(ax_2)
PlotUtilities.title(a.plot_title,color=color)
normalize_and_set_zeros(first_axs,second_axs)
# after normalization, add in the scale bars
for i,(ax_1,ax_2) in enumerate(zip(first_axs,second_axs)):
Scalebar.x_scale_bar_and_ticks_relative(unit="nm",width=5,ax=ax_2,
**kw_scalebars[i])
PlotUtilities.no_x_label(ax_2)
示例6: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
n_samples = int(1e4)
sigma = 1
loc_arr = [-3,-1,0.5]
n_bins = 50
ylim = [0,0.6]
n_cols = 3+1
xlim = [-12,12]
bins = np.linspace(*xlim,endpoint=True,num=n_bins)
fig = PlotUtilities.figure((12,7))
plt.subplot(1,n_cols,1)
bhattacharya,x1,x2 = plot_bhattacharya(sigma,n_samples,bins=bins,
loc=-9)
plt.xlim(xlim)
PlotUtilities.tickAxisFont()
PlotUtilities.xlabel("Distribution Value")
PlotUtilities.ylabel("Probability")
PlotUtilities.legend(frameon=False)
plt.ylim(ylim)
title = p_label(bhattacharya,x1,x2)
PlotUtilities.title(title)
for i,loc in enumerate(loc_arr):
plt.subplot(1,n_cols,(i+2))
bhattacharya,x1,x2 = plot_bhattacharya(sigma,n_samples,bins,
loc=loc)
title = p_label(bhattacharya,x1,x2)
PlotUtilities.title(title)
plt.xlim(xlim)
plt.ylim(ylim)
PlotUtilities.tickAxisFont()
PlotUtilities.no_y_label()
PlotUtilities.legend(frameon=False)
PlotUtilities.xlabel("")
PlotUtilities.savefig(fig,"bcc.pdf",subplots_adjust=dict(wspace=0.1))
示例7: plot_with_background_corrected
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def plot_with_background_corrected(args,imshow_kw_list=None):
n = len(args)
fig = PlotUtilities.figure((3.5,2*n))
for i,a in enumerate(args):
ax = plt.subplot(n,1,(i+1))
m_list = imshow_kw_list[i]
if (m_list['cmap'] == plt.cm.afmhot):
vmin,vmax = realistic_min_max(a)
else:
vmin,vmax = 0,None
imshow_kwargs = dict(vmin=vmin,vmax=vmax,**m_list)
im = ImageUtil.make_image_plot(a,pct=50,imshow_kwargs=imshow_kwargs)
if (i == 0):
ImageUtil.smart_colorbar(im=im,ax=ax,fig=fig)
if (i < n-1):
PlotUtilities.xlabel("",ax=ax)
PlotUtilities.no_x_label(ax=ax)
ImageUtil.smart_colorbar(im=im,ax=ax,fig=fig,add_space_only=True)
else:
ImageUtil.smart_colorbar(im=im,ax=ax,fig=fig,add_space_only=True)
return fig
示例8: plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [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()
#.........这里部分代码省略.........
示例9: rupture_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def rupture_plot(true,pred,fig,count_ticks=3,
scatter_kwargs=None,style_pred=None,
style_true=None,use_legend=True,count_limit=None,
color_pred=None,color_true=None,
bins_load=None,bins_rupture=None,
remove_ticks=True,lim_plot_load=None,lim_plot_force=None,
title="",distance_histogram=None,gs=None,
limit_percentile=True):
if (distance_histogram is None):
n_rows = 2
n_cols = 2
widths = [2,1]
heights = [2,1]
offset=0
else:
n_rows = 2
n_cols = 3
widths = [2,2,1]
heights = [2,2]
offset=1
if (gs is None):
gs = gridspec.GridSpec(n_rows,n_cols,width_ratios=widths,
height_ratios=heights)
subplot_f = lambda x: plt.subplot(x)
ruptures_true,loading_true = \
Learning.get_rupture_in_pN_and_loading_in_pN_per_s(true)
ruptures_pred,loading_pred = \
Learning.get_rupture_in_pN_and_loading_in_pN_per_s(pred)
if (color_pred is None):
color_pred = color_pred_def
if (color_true is None):
color_true = color_true_def
if (style_true is None):
style_true = _style_true(color_true)
if (style_pred is None):
style_pred = _style_pred(color_pred)
if (scatter_kwargs is None):
scatter_kwargs = dict(style_true=dict(label="true",**style_true),
style_predicted=dict(label="predicted",
**style_pred))
_lim_force,_bins_rupture,_lim_load,_bins_load = \
Learning.limits_and_bins_force_and_load(ruptures_pred,ruptures_true,
loading_true,loading_pred,
limit=False)
_lim_force_plot,_bins_rupture_plot,_lim_load_plot,_bins_load_plot = \
Learning.limits_and_bins_force_and_load(ruptures_pred,ruptures_true,
loading_true,loading_pred,
limit=limit_percentile)
if (bins_rupture is None):
bins_rupture = _bins_rupture_plot
if (bins_load is None):
bins_load = _bins_load_plot
if (lim_plot_load is None):
lim_plot_load = _lim_load_plot
if (lim_plot_force is None):
lim_plot_force = _lim_force_plot
if (distance_histogram is not None):
ax_hist = plt.subplot(gs[:,0])
histogram_event_distribution(**distance_histogram)
ax0 = subplot_f(gs[0,offset])
plot_true_and_predicted_ruptures(true,pred,**scatter_kwargs)
PlotUtilities.xlabel("")
plt.xlim(lim_plot_load)
plt.ylim(lim_plot_force)
PlotUtilities.title(title)
if (remove_ticks):
ax0.get_xaxis().set_ticklabels([])
ax1 =subplot_f(gs[0,offset+1])
hatch_true = true_hatch()
true_style_histogram = _histogram_true_style(color_true=color_true,
label="true")
pred_style_histogram = _histogram_predicted_style(color_pred=color_pred,
label="predicted")
# for the rupture force, we dont add the label
rupture_force_true_style = dict(**true_style_histogram)
rupture_force_true_style['label'] = None
rupture_force_pred_style = dict(**pred_style_histogram)
rupture_force_pred_style['label'] = None
rupture_force_histogram(pred,orientation='horizontal',bins=bins_rupture,
**rupture_force_pred_style)
rupture_force_histogram(true,orientation='horizontal',bins=bins_rupture,
**rupture_force_true_style)
PlotUtilities.lazyLabel("Count","","")
ax = plt.gca()
# push count to the top
ax.xaxis.tick_top()
ax.xaxis.set_label_position('top')
if (remove_ticks):
ax1.get_yaxis().set_ticklabels([])
if (count_limit is not None):
plt.xlim(count_limit)
plt.ylim(lim_plot_force)
plt.xscale('log')
ax4 = subplot_f(gs[1,offset])
n_pred,_,_ = loading_rate_histogram(pred,orientation='vertical',
bins=bins_load,
**pred_style_histogram)
n_true,_,_, = loading_rate_histogram(true,orientation='vertical',
bins=bins_load,**true_style_histogram)
#.........这里部分代码省略.........
示例10: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def run(Seq,output_base,
lower_bound_func=lambda *args: 10,
upper_bound_func=lambda *args: 100):
"""
<Description>
Args:
Seq: to analyze
output_base: where to save the files
<lower/upper>_bound_func: return the lower and upper bound in nm
Returns:
This is a description of what is returned.
"""
pass
MolecularWeight = Bio.SeqUtils.molecular_weight(Seq,
seq_type="DNA",
double_stranded=True,
circular=True)
SeqLen = len(Seq)
print("The Molecular weight of your {:d}bp sequence is {:.1f}kDa".\
format(SeqLen,MolecularWeight/1000.))
LengthDoubleStrandedBasePairs = len(Seq)
Avogadro = 6.022e23
MassGramsPerMolecule= MolecularWeight/Avogadro
MoleculesPerCircularMicrogram = 1e-6/MassGramsPerMolecule
KbpPerConstr = SeqLen/1000
# #get the mean distance between molecules on an afm slide
radius = 0.010
Area = np.pi * (radius**2)
# set up an array of DNA amounts loaded
MicrogramsLoaded = np.logspace(-3,2,num=2000)
# convert the micrograms into a concentration, assuming LoadVolume is the
# volume of the DNA
LoadVolumeMicroliters = 20
LoadConcentrationNgPerUl = (MicrogramsLoaded * 1e3)/LoadVolumeMicroliters
# get many molecules that mass translates into
MoleculesLoaded = MoleculesPerCircularMicrogram * MicrogramsLoaded
MolarityLoaded =(MoleculesLoaded/(LoadVolumeMicroliters * 1e-6))/Avogadro
NanoMolarLoaded = MolarityLoaded * 1e9
# get the expected mean distance between molecules, assuming 100%
# binding efficiency
MeanDist = np.sqrt(Area/MoleculesLoaded)
# convert the distance to nanometers
MeanDistNano = MeanDist * 1e9
# get the DNA Size in nm
NanometersPerBp = 0.338
DNASizeNanoMeters = NanometersPerBp * KbpPerConstr * 1000
# maxmium concentration fro QiaQuick is about 300ng/uL in 35uL for 10ug
# anything higher than this is *not* recommended
MaxConcNgPerUl = 300
# the tip radius is O(10nm), persistence length is 43nm, consider that
# as a 'length' of the polymer to find the radius of gyration
Lp_nm = 43
NumPersistence = DNASizeNanoMeters/Lp_nm
# at least N radii of gyration away. Should be more than 2 to prevent
# overlap
RadiusOfGyrLinearNanoMeters = LinearRadiusOfGyration(Lp_nm,
DNASizeNanoMeters)
RadiusOfGyrNanoMeters = CircularRadiusOfGyration(Lp_nm,
DNASizeNanoMeters)
NumAway = 2.5
MinimumSeparationNanoMeters = NumAway*RadiusOfGyrNanoMeters
# plots!
fig = pPlotUtil.figure(figsize=(8,8))
ax1 = plt.subplot(1,1,1)
efficiency = 1./5
PerfectEfficiency = MeanDistNano
plt.loglog(LoadConcentrationNgPerUl,PerfectEfficiency,'g-',linewidth=3,
label="100% efficiency")
# if we have lower efficiency, we are just lowering the number of molecules
# available; singe the mean distance goes like 1/Sqrt(N), then if N_eff is
# N/10 (meaning 10% efficiency), then the mean distance increases by
# sqrt(10)~3
LowerEfficiency= MeanDistNano*np.sqrt(1/efficiency)
# N*L0 should be totally sufficient: DNA at site A must reach all the way
# to site B (tether is complemtary region)
tip_radius_nm = 30
LowerBoundDist = lower_bound_func(tip_radius_nm,DNASizeNanoMeters)
UpperBoundDist = upper_bound_func(tip_radius_nm,DNASizeNanoMeters)
plt.loglog(LoadConcentrationNgPerUl,LowerEfficiency,
'm.-',linewidth=3,
label="{:d}% efficiency".format(int(efficiency*100)))
# bit of a hack to get the label working
xlabel =("Concentration [ng/uL]" +\
"\n({:d}uL Deposition onto {:.1f}mm diameter glass)").\
format(LoadVolumeMicroliters,(2*radius)*1000)
pPlotUtil.lazyLabel(xlabel,
"Expected Mean DNA distance [nm]",
"Tuning Deposition Concentration to avoid dimerization",
titley=1.1)
LegendAndSave(fig,"DepositionAdvice1.png")
plt.axvspan(xmin=MaxConcNgPerUl,xmax=plt.xlim()[-1],color='r',alpha=0.3,
label="Impossible prep")
plt.axhspan(ymin=plt.ylim()[0],ymax=LowerBoundDist,color='k',
alpha=0.3)
plt.axhspan(ymin=UpperBoundDist,ymax=plt.ylim()[-1],color='k',alpha=0.3,
label="Suboptimal for AFM")
# our circular DNA is roughly 607nm
plt.axhline(DNASizeNanoMeters,linewidth=4,linestyle='--',
#.........这里部分代码省略.........
示例11: fmt_iwt
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def fmt_iwt():
PlotUtilities.xlabel("Extension (nm)")
示例12: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
#.........这里部分代码省略.........
# dont let the line cross the textbox
x_upper_idx = np.where(time_rel < 0.67 * max(time_rel))
plt.plot(time[x_upper_idx],line_upper[x_upper_idx],'b--')
plt.plot(time,line_lower,'b--')
xlim = plt.xlim()
ylim = plt.ylim()
# add a little to the x and xlims, so the scale bar has a natural place
# place to go
y_range = abs(np.diff(ylim))
x_range = abs(np.diff(xlim))
ylim = [ylim[0],ylim[1]+y_range*0.05]
xlim = [xlim[0],xlim[1]+x_range*0.01]
ax_tmp.set_ylim(ylim)
ax_tmp.set_xlim(xlim)
min_x = min(xlim)
max_y = max(ylim)
y_loc = max_y*0.9
x_kwargs =dict(unit="ms",width=widths_s[i],
fudge_text_pct=dict(x=0.2,y=0),
unit_kwargs=dict(value_function=lambda x: x * 1e3))
y_kwargs = dict(unit="pN ",
height=heights_pN[i])
offset_x = Scalebar.rel_to_abs(ax_tmp,offsets_x[i],True)
offset_y = Scalebar.rel_to_abs(ax_tmp,offsets_y[i],False)
Scalebar.crossed_x_and_y(offset_x=offset_x,
offset_y=offset_y,
ax=ax_tmp,
x_kwargs=x_kwargs,
y_kwargs=y_kwargs)
PlotUtilities.no_y_label(ax_tmp)
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]
示例13: get_supplemental_figure
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def get_supplemental_figure(output_path,trials):
"""
creates the 'supplemental' timing figure (for use in the appendix)
Args:
see get_main_figure
"""
# XXX should be able to get curve numbers of out pickle
curve_numbers = [1,2,5,10,30,50,100,150,200]
# make a plot comparing *all* of the Big-O plots of the data
plt.subplot(3,2,1)
# sort the times by their loading rates
max_time = max([l.max_time_trial() for l in trials])
min_time = min([l.min_time_trial() for l in trials])
fig = PlotUtilities.figure((16,16))
# plot the Theta(n) coefficient for each
n_rows = 3
n_cols = 2
style_data,style_pred = style_data_and_pred()
x_label = "C (number of curves)"
y_label = "Runtime (s)"
x_label_big_o = "N (points per curve)"
y_label_big_o = "Runtime per curve (s) "
ylim_big_o = [1e-3,1e3]
for i,learner_trials in enumerate(trials):
description = TimePlot.learner_name(learner_trials)
plot_idx = i*n_cols+1
plt.subplot(n_rows,n_cols,plot_idx)
# plot the timing veruses loading rate and number of points
TimePlot.plot_learner_versus_loading_rate_and_number(learner_trials)
fudge_x_low = 20
fudge_x_high = 2
fudge_y = 4
plt.ylim(ylim_big_o)
plt.xlim([1/fudge_x_low,max(curve_numbers)*fudge_x_high])
plt.yscale('log')
plt.xscale('log')
useLegend= (i == 0)
last = (i == (len(trials) - 1))
PlotUtilities.lazyLabel("","","",useLegend=useLegend,frameon=True,
legend_kwargs=dict(fontsize=15))
if (not useLegend):
plt.gca().legend().remove()
PlotUtilities.ylabel(y_label)
if (last):
PlotUtilities.xlabel(x_label)
PlotUtilities.title("Total runtime ({:s})".\
format(description))
plt.subplot(n_rows,n_cols,plot_idx+1)
style_dict = dict(style_data=style_data[i],style_pred=style_pred[i])
TimePlot.plot_learner_slope_versus_loading_rate(learner_trials,
**style_dict)
PlotUtilities.title("Runtime/curve of length N ({:s})".\
format(description))
if (last):
PlotUtilities.xlabel(x_label_big_o)
else:
PlotUtilities.xlabel("")
PlotUtilities.ylabel(y_label_big_o)
plt.ylim(ylim_big_o)
PlotUtilities.label_tom(fig,loc=(-0.05,1.05))
PlotUtilities.savefig(fig, output_path)
# make a plot comparing the constants
pass
示例14: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import xlabel [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
base = FEC_Util.default_data_root()
# XXX use Haos...
absolute_data_dir = "./data_in/"
out_base = "./"
fraction_for_vel = 0.1
# get the region near the first peak
data_iwt = \
CheckpointUtilities.getCheckpoint("./peaks.pkl",
get_first_peak_slices,
False,
absolute_data_dir)
kwargs_fit = dict(kbT = 4.11e-21,
Lp=0.3e-9,
K0=1000e-12)
# get the contour lengths
contour_lengths = \
CheckpointUtilities.getCheckpoint("./contour.pkl",
get_contour_lengths,False,
data_iwt,
kwargs_fit)
# align all of them so that the contour length is at 0+x
offset_nm = 0
iwt_offset = []
for d,L0 in zip(data_iwt,contour_lengths):
tmp = copy.deepcopy(d)
tmp.Extension -= (L0 - offset_nm)
iwt_offset.append(tmp)
# plot *all* of the data, along with the WLC fits...
for i,(r,x0) in enumerate(zip(data_iwt,contour_lengths)):
sep,force = r.Separation,r.Force
grid_x,grid_y,predicted_force = \
WLC.inverted_wlc(sep,force,x0,**kwargs_fit)
fig = PlotUtilities.figure()
FEC_Plot._fec_base_plot(sep*1e9,force*1e12)
plt.plot(grid_x*1e9,grid_y*1e12,color='r')
PlotUtilities.lazyLabel("Separation","Force","")
PlotUtilities.savefig(fig,"./{:d}_FEC.png".format(i))
# plot the data before aligning
fig = PlotUtilities.figure()
FEC_Plot.heat_map_fec(data_iwt)
PlotUtilities.savefig(fig,"heatmap_before.png")
# plot the data after aligning
fig = PlotUtilities.figure()
FEC_Plot.heat_map_fec(iwt_offset)
PlotUtilities.savefig(fig,"heatmap_after.png")
# POST: they are all set. get the IWT
num_bins = 250
pr = cProfile.Profile()
pr.enable()
LandscapeObj = InverseWeierstrass.\
FreeEnergyAtZeroForce(iwt_offset,NumBins=num_bins)
pr.disable()
pr.print_stats(sort='time')
force_N = [1e-12,5e-12,10e-12,20e-12,40e-12,100e-12,250e-12,500e-12]
max_extension_nm = max([max(f.Separation) for f in iwt_offset]) * 1e9
ylim_kT = [-5,None]
for i,f in enumerate(force_N):
xlim_nm = [min(LandscapeObj.Extensions)*1e9,
max_extension_nm]
fig = PlotUtilities.figure(figsize=(6,12))
kw_landscape = dict(f_one_half_N=f)
# # plot the heat map after aligning
plt.subplot(3,1,1)
FEC_Plot.heat_map_fec(iwt_offset,use_colorbar=False)
PlotUtilities.xlabel("")
plt.xlim(xlim_nm)
# # plot the free and tilted landscape
ax_free = plt.subplot(3,1,2)
IWT_Plot.plot_free_landscape(LandscapeObj,**kw_landscape)
PlotUtilities.xlabel("")
plt.xlim(xlim_nm)
plt.ylim(ylim_kT)
# add a second axis for kcal/mol
ylim_kT = np.array(plt.ylim())
ylim_kcal_mol = IWT_Util.kT_to_kcal_per_mol(ylim_kT)
PlotUtilities.secondAxis(ax_free,label="kcal/mol",limits=ylim_kcal_mol,
secondY =True)
ax_tilt = plt.subplot(3,1,3)
IWT_Plot.plot_tilted_landscape(LandscapeObj,fmt_f_label="{:.0f}",
**kw_landscape)
PlotUtilities.xlabel("")
plt.xlim(xlim_nm)
plt.ylim(ylim_kT)
# add another second axis for kcal/mol
PlotUtilities.secondAxis(ax_tilt,label="kcal/mol",limits=ylim_kcal_mol,
secondY =True)
out_name= out_base + "IWT{:d}_{:.1g}.png".format(i,f*1e12)
PlotUtilities.savefig(fig,out_name)