本文整理汇总了Python中GeneralUtil.python.PlotUtilities.no_x_label方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.no_x_label方法的具体用法?Python PlotUtilities.no_x_label怎么用?Python PlotUtilities.no_x_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.no_x_label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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")
示例2: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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")
示例3: plot_subplot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def plot_subplot(subplots,base):
n_subplots = len(subplots)
for i,(name,x,y,range_x,range_y,reversed_flag) in enumerate(subplots):
plt.subplot(n_subplots,1,(i+1))
in_file = base + name + ".png"
im = plt.imread(in_file)
extent = list(range_x) + list(range_y)
if (not reversed_flag):
origin= 'upper'
else:
origin = 'lower'
plt.imshow(im,extent=extent,aspect="auto",origin=origin,
interpolation='bilinear')
if (reversed_flag):
plt.ylim
if (i != n_subplots-1):
PlotUtilities.no_x_label()
PlotUtilities.lazyLabel(x,y,"")
示例4: make_detalied_plots
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def make_detalied_plots(data_to_analyze,areas):
"""
makes the detailed plots
"""
kwargs = landscape_kwargs()
y_limits_pN = [None,None,125,100]
for i,a in enumerate(areas):
fig = PlotUtilities.figure((3.25,5))
mdata = data_to_analyze[i]
example = mdata.landscape[0]
ax = create_landscape_plot(mdata,xlim=None,zero_q=False,**kwargs[i])
ax_heat = ax[0]
PlotUtilities.no_x_label(ax_heat)
ax_heat.relim()
ax_heat.set_ylim([None,y_limits_pN[i]])
out_name = "landscape{:d}_{:s}".format(i,areas[i].plot_title)
axis_func = lambda x: [x[0],x[2]]
PlotUtilities.label_tom(fig,axis_func=axis_func)
PlotUtilities.save_png_and_svg(fig,out_name.replace(" ","_"))
示例5: plot_with_background_corrected
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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
示例6: make_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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")
示例7: helical_gallery_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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)
示例8: plot_residual
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def plot_residual(x_plot,diff_raw,style_raw):
plt.plot(x_plot,f_plot_y(diff_raw),**style_raw)
PlotUtilities.lazyLabel("","Residual (pN)","")
PlotUtilities.no_x_label()
示例9: rupture_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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)
示例10: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
in_dir = "in/"
out_dir = "out/"
ext = ".pkl"
ext_text = ".txt"
GenUtilities.ensureDirExists(out_dir)
image_files = GenUtilities.getAllFiles(in_dir,ext=ext)
text_files = GenUtilities.getAllFiles(in_dir,ext=ext_text)
# filter only to those image files which are 2um
size_images_meters = 2e-6
size_images_pixels = 512
conversion_meters_per_px = size_images_meters / size_images_pixels
objs_all = list(yield_files(image_files,text_files,size_images_meters))
name_func = lambda i,d: "{:s}_img_{:d}".format(d.file_name,i)
load_func = lambda : yield_files(image_files,text_files,size_images_meters)
objs_all = CheckpointUtilities.multi_load(cache_dir=out_dir,
load_func=load_func,
force=True,name_func=name_func)
for o in objs_all:
im = o.image.height_nm_rel()
assert (im.shape[0] == im.shape[1])
assert (im.shape[0] == size_images_pixels)
kw = dict(min_m = 0,max_m = 125e-9)
polymer_info_obj = PolymerTracing.ensemble_polymer_info(objs_all,**kw)
fig = PlotUtilities.figure()
PolymerPlotting.plot_angle_information(polymer_info_obj)
PlotUtilities.savefig(fig,out_dir + "angles.png")
# POST: all the contour lengths are set in 'real' units ]
L0_protein = np.concatenate([o.L0_protein_dna() for o in objs_all])
L0_dna = np.concatenate([o.L0_dna_only() for o in objs_all])
print_info(L0_dna,"only DNA")
print_info(L0_protein,"DNA+PRC2")
n_protein = (L0_protein).size
n_dna = L0_dna.size
fig = PlotUtilities.figure()
n_str = lambda n: "\n(N={:d})".format(n)
sanit_L0 = lambda x: x*1e6
L0_dna_plot = sanit_L0(L0_dna)
L0_protein_plot = sanit_L0(L0_protein)
xmin = np.min(np.concatenate([L0_dna_plot,L0_protein_plot]))
xmax = np.max(np.concatenate([L0_dna_plot,L0_protein_plot]))
n_bins = 12
step = sanit_L0(50e-9)
bins = np.arange(start=0,stop=xmax+step,step=step)
n_bins = bins.size
xlim = [0,xmax*1.1]
kw_dna = dict(color='g',alpha=0.3)
kw_protein = dict(color='b',hatch='//',alpha=0.7)
ax= plt.subplot(2,1,1)
micron_str = "$\mathrm{\mu m}$"
prob_str = "P (1/" + micron_str + ")"
lazy_kw = dict(loc='center left')
prh_hist(L0_dna_plot,normed=True,bins=bins,
label="DNA Only" + n_str(n_dna),**kw_dna)
PlotUtilities.lazyLabel("",prob_str,"",**lazy_kw)
PlotUtilities.no_x_label(ax)
plt.xlim(xlim)
plt.subplot(2,1,2)
prh_hist(L0_protein_plot,normed=True,bins=bins,
label="DNA+PRC2" + n_str(n_protein),**kw_protein)
PlotUtilities.lazyLabel("L$_0$ (" + micron_str + ")",prob_str,"",
**lazy_kw)
plt.xlim(xlim)
PlotUtilities.savefig(fig,out_dir + "hist.png",
subplots_adjust=dict(hspace=0.03))
for obj in objs_all:
# plot each image with all the traces overlayed
fig = PlotUtilities.figure()
plt.imshow(obj.image.height_nm_rel())
# plot each DNA trace
for o in obj.worm_objects:
xy_abs = o.inf.x_y_abs
color = "g" if o.has_dna_bound_protein else "r"
plt.plot(*xy_abs,color=color,linewidth=0.25)
out_name = os.path.basename(obj.image_path)
PlotUtilities.savefig(fig,out_dir + out_name + ".png")
示例11: make_metric_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def make_metric_plot(metrics,
xlim_dist=[1e-5,2],
xlim_load=[1e-2,1e5],
xlim_rupture=[-120,320]):
colors = Plotting.algorithm_colors()
n_rows = 3
n_cols = 3
legend_locs = ['upper right','upper left','upper left']
titles = ["FEATHER","Fovea","Wavelet"]
legend_loading = [None,None,None]
legend_kwargs_style = dict(fontsize=8,handlelength=0.75,handletextpad=0.25)
for i,m in enumerate(metrics):
offset = n_rows * i
# the first column gets the algorithm label; the first row gets the
# metric label
kw_tmp = dict(title_kwargs=dict(fontweight='bold',color='b',fontsize=9),
legend_kwargs=legend_kwargs_style)
if offset == 0:
title_dist = "Location error"
title_load = r"Loading rate (NuG2 + $\mathbf{\alpha_3}$D)"
title_rupture_force = r"Rupture force (NuG2 + $\mathbf{\alpha_3}$D)"
else:
title_dist,title_load,title_rupture_force = "","",""
# only have an x label on the last row
last_row = (offset/n_rows == n_rows-1)
if (last_row):
xlabel_dist = "Relative Error ($\mathbf{x_k}$)"
xlabel_load = "Loading Rate (pN/s)"
xlabel_rupture_force = \
PlotUtilities.variable_string("F_R")
else:
xlabel_dist, xlabel_load,xlabel_rupture_force = "","",""
n_string = r"N_{\mathrm{" + "{:s}".format(titles[i]) + "}}"
ylabel_dist = PlotUtilities.variable_string(n_string)
color_pred=colors[i]
color_true = 'g'
# get the formatting dictionaries for the various plots
distance_histogram_kw= \
Plotting.event_error_kwargs(m,color_pred=color_pred,
label_bool=False)
true_style_histogram = Plotting.\
_histogram_true_style(color_true=color_true,label="true")
pred_style_histogram = Plotting.\
_histogram_predicted_style(color_pred=color_pred,label="predicted")
# get the binning for the rupture force and loading rates
true,pred = m.true,m.pred
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)
_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=False)
# # make the 'just the distance' figures
ax_dist = plt.subplot(n_rows,n_cols,(offset+1))
Plotting.histogram_event_distribution(use_q_number=True,
**distance_histogram_kw)
PlotUtilities.lazyLabel(xlabel_dist,ylabel_dist,title_dist,
loc=legend_locs[i],legendBgColor='w',
frameon=False,**kw_tmp)
PlotUtilities.ylabel(ylabel_dist,fontweight='bold')
plt.xlim(xlim_dist)
if not last_row:
PlotUtilities.no_x_label(ax_dist)
tick_style_log()
# # make the loading rate histogram
ax_load = plt.subplot(n_rows,n_cols,(offset+2))
Plotting.loading_rate_histogram(pred,bins=_bins_load_plot,
**pred_style_histogram)
Plotting.loading_rate_histogram(true,bins=_bins_load_plot,
**true_style_histogram)
plt.xscale('log')
plt.yscale('log')
PlotUtilities.lazyLabel(xlabel_load,"",title_load,
legendBgColor='w',
loc='upper left',frameon=False,**kw_tmp)
plt.xlim(xlim_load)
if not last_row:
PlotUtilities.no_x_label(ax_load)
# get the locations
if legend_loading[i] is not None:
PlotUtilities.legend(loc=(legend_loading[i]),**legend_kwargs_style)
PlotUtilities.no_y_label(ax_load)
tick_style_log()
# # make the rupture force histogram
ax_rupture = plt.subplot(n_rows,n_cols,(offset+3))
Plotting.rupture_force_histogram(pred,bins=_bins_rupture_plot,
**pred_style_histogram)
Plotting.rupture_force_histogram(true,bins=_bins_rupture_plot,
**true_style_histogram)
PlotUtilities.lazyLabel(xlabel_rupture_force,"",title_rupture_force,
useLegend=False,**kw_tmp)
plt.xlim(xlim_rupture)
plt.yscale('log')
if not last_row:
PlotUtilities.no_x_label(ax_rupture)
PlotUtilities.no_y_label(ax_rupture)
tick_style_log(change_x=False)
# set all the y limits for this row
#.........这里部分代码省略.........
示例12: make_pedagogical_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def make_pedagogical_plot(data_to_plot,kw,out_name="./iwt_diagram"):
heatmap_data = data_to_plot.heatmap_data
data = landscape_data(data_to_plot.landscape)
fig = PlotUtilities.figure((3.25,5))
# # ploy the heat map
ax_heat = plt.subplot(3,1,1)
heatmap_plot(heatmap_data,data.amino_acids_per_nm(),
kw_heatmap=kw['kw_heatmap'])
xlim_fec = plt.xlim()
PlotUtilities.no_x_label(ax_heat)
ax_heat.set_ylim([0,150])
PlotUtilities.no_x_label(ax_heat)
PlotUtilities.no_y_label(ax_heat)
fontsize_scalebar = 6
common_kw = dict(color='w',fontsize=fontsize_scalebar)
x_font,y_font = Scalebar.\
font_kwargs_modified(x_kwargs=common_kw,
y_kwargs=common_kw)
heat_kw_common = dict(line_kwargs=dict(color='w',linewidth=1.5))
x_heat_kw = dict(width=15,unit="nm",font_kwargs=x_font,**heat_kw_common)
y_heat_kw = dict(height=30,unit='pN ',font_kwargs=y_font,**heat_kw_common)
# add a scale bar for the heatmap...
scale_bar_x = 0.83
Scalebar.crossed_x_and_y_relative(scale_bar_x,0.55,ax=ax_heat,
x_kwargs=x_heat_kw,
y_kwargs=y_heat_kw)
jcp_fig_util.add_helical_boxes(ax=ax_heat,ymax_box=0.9,alpha=1.0,
font_color='w',offset_bool=True)
# # plot the energy landscape...
ax_correction = plt.subplot(3,1,2)
plot_with_corrections(data)
PlotUtilities.no_x_label(ax_correction)
PlotUtilities.lazyLabel("","Energy (kcal/mol)","")
ax_correction.set_xlim(xlim_fec)
offset_y_pedagogy = 0.42
setup_pedagogy_ticks(ax_correction,scale_bar_x,x_heat_kw,y_heat_kw,
offset_y=offset_y_pedagogy)
legend_font_size = 9
legend = PlotUtilities.legend(handlelength=1.5,loc=(0.15,0.07),ncol=3,
fontsize=legend_font_size,handletextpad=0.4)
for i,text in enumerate(legend.get_texts()):
plt.setp(text, color = kwargs_correction()[i]['color'])
# make the inset plot
axins = zoomed_inset_axes(ax_correction, zoom=3, loc=2,
borderpad=0.8)
plot_with_corrections(data)
xlim_box = [1,5]
ylim_box = [-3,28]
plt.xlim(xlim_box)
plt.ylim(ylim_box)
PlotUtilities.no_x_anything(axins)
PlotUtilities.no_y_anything(axins)
# add in scale bars
kw_common = dict(line_kwargs=dict(linewidth=0.75,color='k'))
common_font_inset = dict(fontsize=fontsize_scalebar)
x_kwargs = dict(verticalalignment='top',**common_font_inset)
x_font,y_font = Scalebar.\
font_kwargs_modified(x_kwargs=x_kwargs,
y_kwargs=dict(horizontalalignment='right',
**common_font_inset))
# set up the font, offset ('fudge') the text from the lines
fudge_x = dict(x=0,y=-0.5)
fudge_y = dict(x=0,y=0.1)
Scalebar.crossed_x_and_y_relative(0.55,0.66,ax=axins,
x_kwargs=dict(width=2,unit="nm",
font_kwargs=x_font,
fudge_text_pct=fudge_x,
**kw_common),
y_kwargs=dict(height=8,unit='kcal/\nmol',
font_kwargs=y_font,
fudge_text_pct=fudge_y,
**kw_common))
# draw a bbox of the region of the inset axes in the parent axes and
# connecting lines between the bbox and the inset axes area
color_box = 'rebeccapurple'
PlotUtilities.color_frame('rebeccapurple',ax=axins)
Annotations.add_rectangle(ax_correction,xlim_box,ylim_box,edgecolor=color_box)
ax_correction.set_xlim(xlim_fec)
ax_energy = plt.subplot(3,1,3)
plot_landscape(data,xlim_fec,kw_landscape=kw['kw_landscape'],
plot_derivative=False,label_deltaG=" ")
ax_energy.set_xlim(xlim_fec)
setup_pedagogy_ticks(ax_energy,scale_bar_x,x_heat_kw,y_heat_kw,
offset_y=offset_y_pedagogy)
# add in the equation notation
strings,colors = [],[]
labels = kwargs_labels()
# add in the appropriate symbols
strings = ["$\Delta G$ = ",labels[0]," + ",labels[1]," - ",labels[2]]
colors_labels = [c['color'] for c in kwargs_correction()]
colors = ["k"] + [item for list in [[c,"k"] for c in colors_labels]
for item in list]
x,y = Scalebar.x_and_y_to_abs(x_rel=0.08,y_rel=0.85,ax=ax_energy)
Annotations.rainbow_text(x,y,strings=strings,colors=colors,
ax=ax_energy,size=legend_font_size)
PlotUtilities.legend(handlelength=0.5,loc=(0.03,0.8))
PlotUtilities.no_x_label(ax_energy)
PlotUtilities.save_png_and_svg(fig,out_name)
示例13: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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
#.........这里部分代码省略.........
示例14: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [as 别名]
def run():
"""
"""
landscape = CheckpointUtilities.lazy_load("./example_landscape.pkl")
# make the landscape relative
landscape.offset_energy(min(landscape.G_0))
landscape.offset_extension(min(landscape.q))
# get the landscape, A_z in kT. Note that we convert z->q, so it is
# really A(q=z-A'/k)
A_q = landscape.A_z
A_q_kT = (A_q * landscape.beta)
# numerically differentiate
to_y = lambda x: x * 1e12
landscape_deriv_plot = to_y(np.gradient(A_q)/np.gradient(landscape.q))
# compare with the A' term. XXX should just save it...
weighted_deriv_plot = to_y(landscape.A_z_dot)
x_plot = landscape.q * 1e9
label_A_q_dot = r"$\dot{A}$"
label_finite = label_A_q_dot + r" from finite difference"
label_work = r"{:s}$ =<<F>>$".format(label_A_q_dot)
kw_weighted = dict(color='m',label=label_work)
fig = PlotUtilities.figure((3.5,5))
# # plot just A(q)
ax_A_q = plt.subplot(3,1,1)
plt.plot(x_plot,A_q_kT,color='c',label="$A$")
PlotUtilities.lazyLabel("","Helmholtz A ($k_\mathrm{b}T$)","",
loc=(0.5,0.8),frameon=True)
PlotUtilities.set_legend_kwargs(ax=ax_A_q,background_color='w',linewidth=0)
PlotUtilities.no_x_label(ax_A_q)
x0 = 14.5
dx = 0.05
xlim = [x0,x0+dx]
# plot the data red where we will zoom in
where_region = np.where( (x_plot >= xlim[0]) &
(x_plot <= xlim[1]))
zoom_x = x_plot[where_region]
zoom_y = A_q_kT[where_region]
ylim = [min(zoom_y),max(zoom_y)]
dy = ylim[1]-ylim[0]
# add in some extra space for the scalebar
ylim_fudge = 0.7
ylim = [ylim[0],ylim[1] + (ylim_fudge * dy)]
lazy_common = dict(title_kwargs=dict(loc='left'))
plt.axvspan(*xlim,color='r',alpha=0.3,edgecolor="None")
plt.plot(zoom_x,zoom_y,color='r')
# plot a zoomed in axis, to clarify why it probably goes wrong
axins = zoomed_inset_axes(ax_A_q, zoom=250, loc=4,borderpad=1)
axins.plot(x_plot, A_q_kT,linewidth=0.1,color='r')
axins.set_xlim(*xlim) # apply the x-limits
axins.set_ylim(*ylim) # apply the y-limits
PlotUtilities.no_x_anything(axins)
PlotUtilities.no_y_anything(axins)
# add in a scale bar for the inset
unit_kw_x = dict(fmt="{:.0f}",value_function=lambda x: x*1000)
common = dict(line_kwargs=dict(linewidth=1.0,color='k'))
# round to ~10s of pm
x_width = np.around(dx/3,2)
y_width = np.around(dy/3,1)
x_kw = dict(width=x_width,unit="pm",unit_kwargs=unit_kw_x,
fudge_text_pct=dict(x=0.2,y=-0.2),**common)
y_kw = dict(height=y_width,unit=r"$k_\mathrm{b}T$",
unit_kwargs=dict(fmt="{:.1f}"),**common)
Scalebar.crossed_x_and_y_relative(ax=axins,
offset_x=0.45,
offset_y=0.7,
x_kwargs=x_kw,
y_kwargs=y_kw)
# # plot A_z_dot
ax_deriv_both = plt.subplot(3,1,2)
# divide by 1000 to get uN
plt.plot(x_plot,landscape_deriv_plot/1e6,color='k',
label=label_finite)
plt.plot(x_plot,weighted_deriv_plot/1e6,**kw_weighted)
PlotUtilities.lazyLabel("",
"$\dot{A}(q)$ ($\mathrm{\mu}$N)",
"$\Downarrow$ Determine derivative (both methods)",
**lazy_common)
PlotUtilities.no_x_label(ax_deriv_both)
# # plot A_z_dot, but just the weighted method (ie: not super wacky)
ax_deriv_weighted = plt.subplot(3,1,3)
plt.plot(x_plot,weighted_deriv_plot,linewidth=1,**kw_weighted)
title_last = "$\Downarrow$ Work-weighted method is reasonable "
PlotUtilities.lazyLabel("Extension (nm)","$\dot{A}(q)$ (pN)",
title_last,**lazy_common)
PlotUtilities.savefig(fig,"./finite_differences.png",
subplots_adjust=dict(hspace=0.2))
示例15: plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_x_label [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()
#.........这里部分代码省略.........