本文整理汇总了Python中GeneralUtil.python.PlotUtilities.lazyLabel方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.lazyLabel方法的具体用法?Python PlotUtilities.lazyLabel怎么用?Python PlotUtilities.lazyLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.lazyLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SavePlot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def SavePlot(SortByZ,FullName,SaveName):
Objs = FEC_Util.ReadInData(FullName)
Tmp = Objs[0]
if (SortByZ):
ArgSort = np.argsort(Tmp.Zsnsr)
Tmp.Zsnsr = Tmp.Zsnsr[ArgSort]
Tmp.Force = Tmp.Force[ArgSort]
Offset = 150
else:
Offset = 0
# set up the y limits in pN
ylim = [Offset-20,Offset+25]
fig = pPlotUtil.figure()
plt.subplot(2,1,1)
FullPlot(Tmp)
pPlotUtil.lazyLabel("Stage position (nm)","Force (pN)","Flickering for FEC",
frameon=True)
# x limits for 'zoomed in'
plt.xlim([30,40])
plt.ylim(ylim)
plt.subplot(2,1,2)
FullPlot(Tmp)
pPlotUtil.lazyLabel("Stage position (nm)","Force (pN)","",frameon=True)
# x limits for 'zoomed in'
plt.xlim([36,36.5])
plt.ylim(ylim)
pPlotUtil.savefig(fig,SaveName)
示例2: FEC_AlreadySplit
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def FEC_AlreadySplit(Appr,Retr,
XLabel = "Separation (nm)",
YLabel = "Force (pN)",
ConversionOpts=def_conversion_opts,
PlotLabelOpts=dict(),
PreProcess=False,
NFilterPoints=50,
LegendOpts=dict(loc='best'),
**kwargs):
"""
Args:
XLabel: label for x axis
YLabel: label for y axis
ConversionOpts: see FEC_Util.SplitAndProcess
PlotLabelOpts: see arguments after filtering of ApproachRetractCurve
PreProcess: if true, pre-processes the approach and retract separately
(ie: to zero and flip the y axis).
NFilterPoints: see FEC_Util.SplitAndProcess, for Savitsky-golay
PreProcess: passed to
"""
ApprCopy = FEC_Util.UnitConvert(Appr,**ConversionOpts)
RetrCopy = FEC_Util.UnitConvert(Retr,**ConversionOpts)
if (PreProcess):
ApprCopy,RetrCopy = FEC_Util.PreProcessApproachAndRetract(ApprCopy,
RetrCopy,
**kwargs)
_ApproachRetractCurve(ApprCopy,RetrCopy,
NFilterPoints=NFilterPoints,**PlotLabelOpts)
PlotUtilities.lazyLabel(XLabel,YLabel,"")
PlotUtilities.legend(**LegendOpts)
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
file_name = "defl.ibw"
defl_volts_wave = PxpLoader.read_ibw_as_wave(file_name)
defl_volts = defl_volts_wave.DataY
invols_nm_per_volt = 154.8
spring_pN_per_nM = 5.70
force_pN = defl_volts * invols_nm_per_volt * spring_pN_per_nM
# zero out to the maximum
force_pN -= np.mean(force_pN)
data_interval_in_s = 1/500e3
rate = 1/float(data_interval_in_s) # data rate in Hz
taus = np.logspace(-5,2,num=50,base=10) # tau-values in seconds
# fractional frequency data
(taus_used, adev, adeverror, adev_n) = \
allantools.adev(force_pN, data_type='freq', rate=rate, taus=taus)
fig = PlotUtilities.figure()
plt.errorbar(x=taus_used,y=adev,yerr=2*adeverror,label="95% C.I.")
plt.xscale('log')
plt.yscale('log')
plt.axhline(1,color='r',linestyle='--',label="1 pN")
PlotUtilities.lazyLabel("Averaging time (s)","Force (pN)","")
PlotUtilities.savefig(fig,"out.png")
示例4: cross_validation_distance_metric
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def cross_validation_distance_metric(x_values,train_scores,valid_scores,
to_true):
"""
Plots the cross validation training and validation distance metric
Args:
x_values: x values
<train/valid>_scores: the training and validation scores used
to_true: distance metric plotted is *from* predicted *to* true
(ie: something like recall) if true, otherwise vice versa
Returns:
nothing
"""
# get the metrics and errors by parameters
x_train,train_dist,train_dist_std = \
Learning.median_dist_metric(x_values,train_scores,to_true=to_true)
x_valid,valid_dist,valid_dist_std = \
Learning.median_dist_metric(x_values,valid_scores,to_true=to_true)
y_plot = lambda y: y * 1e9
train_dist_plot,train_error_plot = y_plot(train_dist),y_plot(train_dist_std)
valid_dist_plot,valid_error_plot = y_plot(valid_dist),y_plot(valid_dist_std)
plt.errorbar(x=x_train,y=train_dist_plot,yerr=train_error_plot,
**style_train)
plt.errorbar(x=x_valid,y=valid_dist_plot,yerr=valid_error_plot,
**style_valid)
plt.xscale('log')
plt.yscale('log')
PlotUtilities.lazyLabel("Tuning Parameter","Median event distance (nm)","",
frameon=False)
示例5: plot_classification
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def plot_classification(split_object,scoring_object):
"""
plots the classification of a single object
Args:
split_object: whatever was classified
scoring_object: Scoring.score object, used on split_object
Returns:
Nothing
"""
retract = split_object.retract
time,force = retract.Time,retract.Force
true_idx,pred_idx = scoring_object.idx_true,scoring_object.idx_predicted
boolean_true,boolean_predicted = scoring_object.get_boolean_arrays(time)
plt.subplot(2,1,1)
plt.plot(time,force,color='k',alpha=0.3)
highlight_events(true_idx,time,force,color='r',linestyle='-',
label="true events")
highlight_events(pred_idx,time,force,color='b',linestyle='None',
marker='.',label="predicted events")
PlotUtilities.lazyLabel("","Force(pN)","")
plt.subplot(2,1,2)
plt.plot(time,boolean_true,linewidth=4,label="True events",color='b')
plt.plot(time,boolean_predicted,label="Predicted",color='r',alpha=0.3)
PlotUtilities.lazyLabel("Time (s)","Force(pN)","")
示例6: landscape_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def landscape_plot(landscape,landscape_rev,landscape_rev_only,kT,f_one_half):
ToX = lambda x: x*1e9
landscape_rev_kT = landscape_rev.G_0/kT
landscape_fwd_kT = landscape.G_0/kT
landscape_rev_only_kT = landscape_rev_only.G_0/kT
ext_fwd = landscape_rev.q
ext_rev = landscape.q
# tilt one of the landscapes
ext_tilt = ext_fwd
landscape_tilt_kT = landscape_rev_kT
landscape_fonehalf_kT = (landscape_tilt_kT*kT-ext_tilt* f_one_half)/kT
landscape_fonehalf_kT_rel = landscape_fonehalf_kT-min(landscape_fonehalf_kT)
xlim = [195,265]
plt.subplot(2,1,1)
sanit = lambda x: x - min(x)
# add in the offsets, since we dont simulate before...
plt.plot(ToX(ext_fwd),sanit(landscape_rev_kT)+20,color='r',alpha=0.6,
linestyle='-',linewidth=3,label="Bi-directional")
plt.plot(ToX(ext_rev),sanit(landscape_fwd_kT)+75,color='b',
linestyle='--',label="Only Forward")
plt.plot(ToX(landscape_rev_only.q),sanit(landscape_rev_only_kT)+20,
"g--",label="Only Reverse")
PlotUtilities.lazyLabel("","Free Energy (kT)",
"Hummer 2010, Figure 3")
plt.xlim(xlim)
plt.ylim([0,300])
plt.subplot(2,1,2)
plt.plot(ToX(ext_tilt),2.5+landscape_fonehalf_kT_rel,'g^',
markevery=10)
plt.xlim(xlim)
plt.ylim([0,25])
PlotUtilities.lazyLabel("Extension q (nm)","Energy at F_(1/2) (kT)","")
示例7: distance_distribution_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def distance_distribution_plot(learner,box_kwargs=None,**kwargs):
"""
plots the distribution of distances to/from predicted events from/to
actual events, dependning on kwargs
Args:
learner: the learner object to use
kwargs: passed to event_distance_distribution (ie: to_true=T/F)
"""
train_scores = learner._scores_by_params(train=True)
valid_scores = learner._scores_by_params(train=False)
if (box_kwargs is None):
box_kwargs = dict(whis=[5,95])
name = learner.description.lower()
x_values = learner.param_values()
train_dist = Learning.event_distance_distribution(train_scores,**kwargs)
valid_dist = Learning.event_distance_distribution(valid_scores,**kwargs)
dist_plot = lambda x: [v for v in x]
train_plot = dist_plot(train_dist)
valid_plot = dist_plot(valid_dist)
plt.boxplot(x=train_plot,**box_kwargs)
plt.boxplot(x=valid_plot,**box_kwargs)
plt.gca().set_yscale('log')
PlotUtilities.lazyLabel("Tuning parameter","Distance Distribution (idx)",
"Event distributions for {:s}".format(name),
frameon=False)
示例8: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def run(base="./"):
"""
"""
name = "examples.pdf"
data_base = base + "data/"
file_names = ["protein","fast_unfolding","low-snr","ringing"]
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]
for c in cases:
split_fec = Analysis.zero_and_split_force_extension_curve(c)
name = c.Meta.Name
num = 0
retract_idx = split_fec.get_predicted_retract_surface_index()
split_fec.retract.Force -= \
np.percentile(split_fec.retract.Force[retract_idx:],25)
predicted_event_idx = Detector.predict(c,threshold=1e-2)
fig = PlotUtilities.figure((8,4))
plot_retract_with_events(split_fec)
num = label_and_save(fig=fig,name=name,num=num)
fig = PlotUtilities.figure((8,4))
plot_events_by_colors(split_fec,predicted_event_idx)
num = label_and_save(fig=fig,name=name,num=num)
fig = PlotUtilities.figure((6,10))
plt.subplot(2,1,1)
plot_events_by_colors(split_fec,predicted_event_idx,plot_filtered=True)
PlotUtilities.lazyLabel("","Force (pN)","")
PlotUtilities.no_x_label()
plt.subplot(2,1,2)
plot_state_transition_diagram(split_fec,predicted_event_idx)
num = label_and_save(fig=fig,name=name,num=num,ylabel="State")
示例9: plot_learner_versus_loading_rate_and_number
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def plot_learner_versus_loading_rate_and_number(learner_trials):
"""
makes a plot of the runtimes versus number of force extension curves
for each loading rate used.
Args:
learner_trials: a single learner object
Returns:
nothing, makes a pretty plot
"""
styles = [dict(color='r',marker='x',linestyle='--'),
dict(color='b',marker='o',linestyle='-'),
dict(color='k',marker='v',linestyle='-.'),
dict(color='g',marker='s',linestyle='-',linewidth=3),
dict(color='m',marker='*',linestyle='-.',linewidth=3),
dict(color='k',marker='8',linestyle='-',linewidth=2),
dict(color='r',marker='p',linestyle='-.',linewidth=2),
dict(color='b',marker='d',linestyle='--'),
dict(color='k',marker='<',linestyle='-'),
dict(color='g',marker='+',linestyle='-.')]
inf = timing_info(learner_trials)
pts,xerr = _timing_plot_pts_and_pts_error(inf,factor=1)
for i,(num,mean,yerr,vel) in enumerate(zip(inf.nums,inf.means,inf.stdevs,
inf.velocities)):
style = styles[i % len(styles)]
velocity_label = r"v={:4d}nm/s".format(int(vel))
number_pretty = r"N$\approx$" + pretty_exp(pts[i])
label = "{:s}\n({:s})".format(velocity_label,number_pretty)
plt.errorbar(x=num,y=mean,yerr=yerr,label=number_pretty,alpha=0.7,
**style)
title = "Runtime verus loading rate and number of curves\n" + \
"(N, points/curve, in parenthesis) "
PlotUtilities.lazyLabel("Number of Force-Extension Curves","Time",title)
示例10: fmt
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def fmt(remove_x_labels=True,remove_y_labels=True):
ax = plt.gca()
if (remove_x_labels):
ax.xaxis.set_ticklabels([])
if (remove_y_labels):
ax.yaxis.set_ticklabels([])
PlotUtilities.lazyLabel("","","")
plt.ylim([-25,80])
plt.xlim([-100,700])
示例11: heatmap_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def heatmap_plot(heatmap_data,amino_acids_per_nm,kw_heatmap=dict()):
ax_heat = plt.gca()
make_heatmap(*heatmap_data,kw_heatmap=kw_heatmap)
PlotUtilities.lazyLabel("","Force (pN)","")
# make a second x axis for the number of ammino acids
xlim_fec = plt.xlim()
limits = np.array(xlim_fec) * amino_acids_per_nm
tick_kwargs = dict(axis='both',color='w',which='both')
ax_heat.tick_params(**tick_kwargs)
plt.xlim(xlim_fec)
示例12: probability_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def probability_plot(inf,slice_eq):
plt.subplot(2,1,1)
plt.plot(inf.ext_bins_safe,inf.p_k)
plt.plot(inf.ext_bins,inf.P_q,'r--')
plt.plot(inf.ext_interp,inf.p_k_interp,'g-')
PlotUtilities.lazyLabel("","PDF","")
plt.subplot(2,1,2)
plt.plot(inf.ext_bins_safe,inf.free_energy_kT,'g-')
plt.plot(inf.ext_bins,inf.convolved_free_energy_kT,'r--')
PlotUtilities.lazyLabel(r"Extension ($\AA$)","Free energy","")
示例13: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def run():
"""
Describes why we are picking the fluorophores we are
"""
# get the excitation filter
filter_file = "lumencor_631_28_nm.txt"
arr = np.loadtxt(filter_file,skiprows=1)
wavelength,filter_value = arr[:,0],arr[:,1]
# convert from 0 to 1 transmission (from 0 to 100)
filter_value /= 100
# get the fluorophore
# (see: http://www.fluorophores.tugraz.at/substance/418)
fluorophore_file = "atto_5382.csv"
arr = np.loadtxt(fluorophore_file,skiprows=1,delimiter=";",
usecols=(0,1,2,3))
wavelength_fluorophore_excitation_nm,excitation = arr[:,0],arr[:,1]
wavelength_fluorophore_emission_nm,emission = arr[:,2],arr[:,3]
# get the emission filter
# see: laser2000.co.uk/semrock_filter.php?code=FF01-680/42-25
emission_filter_file = "FF01-680_42.txt"
arr_emit = np.loadtxt(emission_filter_file,skiprows=4)
wavelength_emission_filter,emission_filter = arr_emit[:,0],arr_emit[:,1]
# plot the fluorophores
label_excite_emit = "\n({:s})".format(fluorophore_file)
wavelength_limits_nm = [500,800]
fig = PlotUtilities.figure((5,6))
plt.subplot(2,1,1)
plt.plot(wavelength,filter_value,
label=("Filter (excitation)\n" + filter_file))
plt.plot(wavelength_fluorophore_excitation_nm,excitation,
label="Fluorophore Excitation" + label_excite_emit,
linestyle='--')
PlotUtilities.lazyLabel("","Excitation efficiency","")
plt.xlim(wavelength_limits_nm)
PlotUtilities.no_x_label()
plt.subplot(2,1,2)
plt.plot(wavelength_emission_filter,emission_filter,
label="Filter (emission) \n" + emission_filter_file)
plt.plot(wavelength_fluorophore_emission_nm,emission,
label="Flurophore Emission" + label_excite_emit,
linestyle='--')
plt.xlim(wavelength_limits_nm)
PlotUtilities.lazyLabel("Wavelength (nm)","Emission efficiency","")
PlotUtilities.savefig(fig,"./filter_comparisons.png")
p1607F,_ = CommonPrimerUtil.Get1607FAnd3520R("../..")
# add a dbco and a fluorophore...
seq_full = [IdtUtil.Dbco5Prime()] + [s for s in p1607F] + \
[IdtUtil.atto_633()]
# get the IDT order
opts = dict(Scale=IdtUtil.Scales._100NM,
Purification=IdtUtil.Purifications.HPLC)
order = IdtUtil.\
SequencesAndNamesTuplesToOrder( [(seq_full,"AzideTestFluorophore")],
**opts)
IdtUtil.PrintAndSave(order,"./test_azide_fluorophore.txt")
示例14: plot_learner_slope_versus_loading_rate
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def plot_learner_slope_versus_loading_rate(learner_trials,style_data=None,
style_pred=None,min_pred=1e-3):
"""
Makes a plot of the (slope of runtime versus number of curves) versus
loading rate
Args:
learner_trials: a single learner object
style_<data/pred>: style for the data points and predictions
Returns:
nothing, makes a pretty plot
"""
if (style_data is None):
style_data = dict(color='r',linestyle="None",marker='o')
if (style_pred is None):
style_pred = dict(color='b',linestyle="--")
inf = timing_info(learner_trials)
marker =style_data['marker']
params,params_std = get_loading_rate_slopes_and_errors(inf)
# the slope is the time per force extension curve (less an offset; get that
# per loading rate
velocities = inf.velocities
x,xerr = _timing_plot_pts_and_pts_error(inf)
coeffs,coeffs_err,x_pred,y_pred = get_linear_runtime(x,params)
# fit a linear model to the runtime
fudge = 2
plt.plot(x=x,xerr=xerr,y=params,yerr=params_std,markersize=1,**style_data)
slope = coeffs[0]
lower_label = r"{:.2f}$ c_0 N \leq $".format(fudge)
upper_label = r"$\leq \frac{c_0}{" + "{:.2f}".format(fudge) + "} N$"
label_timing = learner_name(learner_trials)
style_timing = style_pred
condition = y_pred > 1e-2
idx_good = np.where(condition)[0]
idx_bad = np.where(~condition)[0]
x_pred_plot = x_pred[idx_good]
y_pred_plot = y_pred[idx_good]
# only plot where the prediction is reasonable
plt.plot(x_pred_plot,y_pred_plot/fudge,**style_timing)
plt.plot(x_pred_plot,y_pred_plot*fudge,**style_timing)
# plot where _not _reasonable_
style_not_reasonable = dict(**style_timing)
style_not_reasonable['color']='k'
style_not_reasonable['alpha']=0.3
plt.plot(x_pred[idx_bad],y_pred[idx_bad]/fudge,**style_not_reasonable)
plt.plot(x_pred[idx_bad],y_pred[idx_bad]*fudge,**style_not_reasonable)
ax = plt.gca()
ax.set_xscale('log')
ax.set_yscale('log')
# plot something just for the legend entry
plt.plot([],[],label=label_timing.replace(" ","\n"),marker=marker,
**style_timing)
PlotUtilities.lazyLabel("N (points per curve)",
"Runtime per curve (s)",
"Runtime per curve, T(N), is $\Theta(\mathrm{N})$")
示例15: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import lazyLabel [as 别名]
def run():
"""
Generates FRET histograms from NaCl and KCl data
"""
data = ReadNaCl("./Data/NaCl")
dataKcl = ReadKCl("./Data/KCl")
# assume number of histograms is the same
NumHists = len(data)
fig = pPlotUtil.figure(figsize=(12,16))
CommonStyle = dict(alpha=0.3,linewidth=0)
StyleDicts = [dict(color='m',label="0mM NaCl",**CommonStyle),
dict(color='r',label="1mM NaCl",**CommonStyle),
dict(color='k',label="10mM NaCl",**CommonStyle),
dict(color='c',label="25mM NaCl",**CommonStyle),
dict(color='g',label="50mM NaCl",**CommonStyle),
dict(color='b',label="100mM NaCl",**CommonStyle)]
# for style, just replace label 'NaCl' with 'KCL'
StyleDictKCL = copy.deepcopy(StyleDicts)
for i,TmpDict in enumerate(StyleDictKCL):
TmpDict['label'] = TmpDict['label'].replace("NaCl","KCl")
TmpDict['alpha'] = 0.7
TmpDict['linewidth'] = 0.5
# determine the bounds for the FRET
MinFret = -0.25
MaxFretFromData = np.max([max(arr) for arr in data])
MaxFret = 1.2
# assume a-priori knowledge of the bin counts
MinBin = 0
MaxBin = 140
StepFret = 0.01
ylim = [MinBin,MaxBin]
bins = np.arange(MinFret,MaxFret,StepFret)
for i,histogram in enumerate(data):
title = "High salt induces GQ folding" \
if i == 0 else ""
# plot the NaCl data
plt.subplot(NumHists,2,(2*i+1))
plt.hist(histogram,bins=bins,**StyleDicts[i])
AxesDefault(ylim,title,"Count",UseYTicks=True)
plt.subplot(NumHists,2,2*(i+1))
plt.hist(dataKcl[i],bins=bins,**StyleDictKCL[i])
AxesDefault(ylim,"","",UseYTicks=False)
# plot the KCl Data
plt.subplot(NumHists,2,11)
ax = plt.gca()
plt.setp(ax.get_xticklabels(),visible=True)
plt.setp(ax.get_yticklabels(),visible=True)
pPlotUtil.lazyLabel("FRET","Count","",frameon=True)
plt.subplot(NumHists,2,12)
ax = plt.gca()
plt.setp(ax.get_xticklabels(),visible=True)
pPlotUtil.lazyLabel("FRET","","",frameon=True)
pPlotUtil.savefig(fig,"./out.png")