本文整理汇总了Python中GeneralUtil.python.PlotUtilities.no_y_label方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.no_y_label方法的具体用法?Python PlotUtilities.no_y_label怎么用?Python PlotUtilities.no_y_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.no_y_label方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_pedagogy_ticks
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_label [as 别名]
def setup_pedagogy_ticks(ax,scale_bar_x,x_heat_kw,y_heat_kw,offset_y=0.9):
font_kwargs= copy.deepcopy(Scalebar.def_font_kwargs_y)
# fix the keywords relative to the heatmap
x_heat_kw['font_kwargs']['color'] = 'k'
x_heat_kw['line_kwargs']['color'] = 'k'
y_heat_kw['font_kwargs']['color'] = 'k'
y_heat_kw['line_kwargs']['color'] = 'k'
y_heat_kw['unit'] = 'kcal/mol '
y_heat_kw['height'] = 40
Scalebar.crossed_x_and_y_relative(scale_bar_x,offset_y,ax=ax,
x_kwargs=x_heat_kw,
y_kwargs=y_heat_kw)
PlotUtilities.no_y_label(ax)
示例2: plot_fec_cartoon
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_label [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: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_label [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))
示例4: plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_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()
#.........这里部分代码省略.........
示例5: make_metric_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_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
#.........这里部分代码省略.........
示例6: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_label [as 别名]
#.........这里部分代码省略.........
ax_final_prob = plt.subplot(gs[3,:])
plt.plot(time_plot,to_prob_plot(info_final.cdf),
**probability_kwargs)
title_consistent = (arrow + "Supress small force change events")
PlotUtilities.lazyLabel("",probability_label_post,title_consistent,**kw)
PlotUtilities.no_x_label(ax_final_prob)
plt.ylim(ylim_prob)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final_prob,**prob_scale_dict)
tick_style()
# # plot the final event locations
ax_final = plt.subplot(gs[4,:])
plt.plot(time_plot,force_plot,**raw_force_kwargs)
plt.plot(time_plot,force_interp_plot,**interp_force_kwargs)
PlotUtilities.no_x_label(ax_final)
title_final = (arrow + " Extract significant events")
event_starts = [e.start for e in info_final.event_slices_raw]
Plotting.plot_arrows_above_events(event_starts,plot_x=time_plot,
plot_y=force_plot,fudge_y=40,
label=None)
PlotUtilities.lazyLabel("",force_label,title_final,
loc = "upper center",**kw)
plt.ylim(ylim_force_pN)
plt.xlim(xlim_time)
Scalebar.x_scale_bar_and_ticks_relative(ax=ax_final,**fec_scale_dict)
tick_style()
ylim_first_event = [-5,30]
first_event_window_large = 0.045
fraction_increase= 5
color_first = 'm'
# get the event index, window pct to use, where to show a 'zoom', and the
# y limits (if none, just all of it)
event_idx_fudge_and_kw = \
[ [0 ,first_event_window_large ,True,ylim_first_event,color_first],
[0 ,first_event_window_large/fraction_increase,False,
ylim_first_event,color_first],
[-1,4e-3,True,[-50,None],'r']]
widths_seconds = 1e-3 * np.array([50,10,5])
for i,(event_id,fudge,zoom_bool,ylim,c) in \
enumerate(event_idx_fudge_and_kw):
# get how the interpolated plot should be
interp_force_kwargs_tmp = dict(**interp_force_kwargs)
interp_force_kwargs_tmp['color'] = c
interp_force_kwargs_tmp['linewidth'] = 1.25
# determine the slice we want to use
event_location = info_final.event_idx[event_id]
event_bounding_slice = slice_window_around(event_location,
time_plot,fraction=fudge)
time_first_event_plot = time_plot[event_bounding_slice]
time_slice = time_first_event_plot
# # plot the interpolated on the *full plot* before we zoom in (so the
# # colors match)
plt.subplot(gs[-2,:])
plt.plot(time_slice,force_interp_plot[event_bounding_slice],
**interp_force_kwargs_tmp)
plt.ylim(ylim_force_pN)
# # next, plot the zoomed version
in_ax = plt.subplot(gs[-1,i])
in_ax.plot(time_slice,force_plot[event_bounding_slice],
**raw_force_kwargs)
in_ax.plot(time_slice,force_interp_plot[event_bounding_slice],
**interp_force_kwargs_tmp)
PlotUtilities.no_x_anything(ax=in_ax)
# removing y label on all of them..
if (i == 0):
ylabel = force_label
else:
ylabel = ""
# determine if we need to add in 'guidelines' for zooming
if (zoom_bool):
PlotUtilities.zoom_effect01(ax_final,in_ax,*in_ax.get_xlim(),
color=c)
PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
else:
# this is a 'second' zoom in...'
PlotUtilities.no_y_label(in_ax)
ylabel = ("{:d}x\n".format(fraction_increase)) + \
r"$\rightarrow$"
PlotUtilities.lazyLabel("Time (s)",ylabel,"",**kw)
PlotUtilities.ylabel(ylabel,rotation=0,labelpad=5)
# plot an arrow over the (single) event
Plotting.plot_arrows_above_events([event_location],plot_x=time_plot,
plot_y=force_plot,fudge_y=7,
label=None,markersize=150)
plt.ylim(ylim)
common = dict(unit="ms",
unit_kwargs=dict(value_function = lambda x: x*1e3))
width = widths_seconds[i]
Scalebar.x_scale_bar_and_ticks_relative(offset_y=0.1,offset_x=0.5,
width=width,ax=in_ax,
**common)
PlotUtilities.tom_ticks(ax=in_ax,num_major=2,change_x=False)
loc_major = [-0.15,1.2]
loc_minor = [-0.15,1.15]
locs = [loc_major for _ in range(5)] + \
[loc_minor for _ in range(3)]
PlotUtilities.label_tom(fig,loc=locs)
subplots_adjust=dict(hspace=0.48,wspace=0.35)
PlotUtilities.save_png_and_svg(fig,"flowchart",
subplots_adjust=subplots_adjust)
示例7: make_pedagogical_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_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)
示例8: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import no_y_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
#.........这里部分代码省略.........