本文整理汇总了Python中GeneralUtil.python.PlotUtilities.label_tom方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.label_tom方法的具体用法?Python PlotUtilities.label_tom怎么用?Python PlotUtilities.label_tom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.label_tom方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run():
"""
<Description>
Args:
param1: This is the first param.
Returns:
This is a description of what is returned.
"""
data_file = "../_Data/Scores.pkl"
kw = dict(score_tx_func=get_only_nug2_ruptures)
runs = [ ["./cache.pkl",dict(),"performance"],
["./cache_nug2.pkl",kw,"performance_nug2"]]
PlotUtilities.tom_text_rendering()
for cache_name,keywords,plot_name in runs:
# get the metrics we care about
metrics = CheckpointUtilities.getCheckpoint(cache_name,
Offline.get_best_metrics,
False,data_file,
**keywords)
coeffs_compare = [m.coefficients() for m in metrics]
write_coeffs_file("./coeffs.txt",coeffs_compare)
# make the plot we want
fig = PlotUtilities.figure(figsize=(7,3))
make_metric_plot(metrics)
axis_func = lambda axes: [ax for i,ax in enumerate(axes) if i < 3]
loc_last_two = [-0.05,1.1]
locs = [ [-0.2,1.1], loc_last_two,loc_last_two]
PlotUtilities.label_tom(fig,axis_func=axis_func,loc=locs)
# save out the plot
subplots_adjust = dict(hspace=0.1,wspace=0.1,
bottom=0.125,top=0.93)
PlotUtilities.save_png_and_svg(fig,plot_name,
subplots_adjust=subplots_adjust)
示例2: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(base="./"):
"""
"""
out_base = base
data_base = base + "data/"
data_file = "../FigurePerformance_CS/data/Scores.pkl"
force=False
cache_file = base + "cache.pkl"
fec_file = data_base + "multiple.csv.pkl"
name = "FEATHER"
final_out_hist = "{:s}{:s}_distances.pdf".format(out_base,
name.replace(" ","_"))
l = CheckpointUtilities.getCheckpoint(cache_file,get_feather_run,force,
data_file)
# make the distance histogram figure for the presenation
fig = PlotUtilities.figure((10,5))
make_distance_figure(l,data_file,fec_file)
PlotUtilities.legend(loc='upper right')
PlotUtilities.savefig(fig,final_out_hist.replace(".pdf","_pres.pdf"))
# make the distance histogram figure
fig = PlotUtilities.figure((16,6))
make_distance_figure(l,data_file,fec_file)
PlotUtilities.legend(loc='upper right')
PlotUtilities.label_tom(fig,loc=(-0.1,1.0),fontsize=18)
PlotUtilities.savefig(fig,final_out_hist)
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(base="./"):
"""
"""
name = "cartoon.pdf"
data_base = base + "data/"
file_names = ["no","single","multiple"]
# save without the labels for the presentation
subplots_adjust = dict(left=0.12,wspace=0.2,hspace=0.1)
fig = PlotUtilities.figure((8,4))
plot_fec_cartoon(base,data_base,file_names,
arrow_kwargs=dict(markersize=75))
PlotUtilities.savefig(fig,name.replace(".pdf","_pres.pdf"),
subplots_adjust=subplots_adjust)
# save with the labels for the presentation
fig = PlotUtilities.figure((16,8))
subplots_adjust = dict(left=0.08,wspace=0.2,hspace=0.1)
plot_fec_cartoon(base,data_base,file_names,
arrow_kwargs=dict(markersize=125))
n_subplots = 2
n_categories = len(file_names)
letters = string.uppercase[:n_categories]
letters = ([r"{:s}".format(s) for s in letters] + \
["" for _ in range(n_categories)])
bottom = (-0.25,1)
top = (-0.60,1)
loc = [top for i in range(n_categories)] + \
[bottom for i in range(n_categories)]
PlotUtilities.label_tom(fig,letters,loc=loc)
PlotUtilities.savefig(fig,name,subplots_adjust=subplots_adjust)
示例4: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(in_base="./"):
"""
"""
out_base = "./"
data_file = in_base + "data/Scores.pkl"
force=False
cache_file = out_base + "cache.pkl"
metrics = CheckpointUtilities.getCheckpoint(cache_file,get_best_metrics,
force,data_file)
loc_left = (-0.15,1.1)
loc_top = (-0.15,1.05)
loc_lower = (-0.15,0.95)
locs = [loc_top,loc_left,loc_left,loc_lower,loc_lower]
titles = Plotting.algorithm_title_dict()
colors = Plotting.algorithm_colors()
for i,m in enumerate(metrics):
name = titles[m.name.lower()]
safe_name = name.replace(" ","")
color_pred = colors[i]
distance_histogram= Plotting.event_error_kwargs(m,color_pred=color_pred)
true,pred = m.true,m.pred
# make the 'just the distance' figures
fig = PlotUtilities.figure((10,6))
Plotting.histogram_event_distribution(**distance_histogram)
final_out_dist = "{:s}{:s}_dist_full.pdf".format(out_base,safe_name)
PlotUtilities.savefig(fig,final_out_dist)
# make the rupture spectrum figure
fig = PlotUtilities.figure((12,7))
final_out_rupture = "{:s}{:s}_rupture_full.pdf".\
format(out_base,safe_name)
Plotting.rupture_plot(true,pred,fig=fig)
PlotUtilities.savefig(fig,final_out_rupture)
fig = PlotUtilities.figure((7,4))
# plot the metric plot
Plotting.rupture_plot(true,pred,use_legend=True,
distance_histogram=distance_histogram,
fig=fig,color_pred=color_pred)
final_out_path = "{:s}{:s}_full.pdf".format(out_base,safe_name)
PlotUtilities.label_tom(fig,loc=locs)
plt.suptitle(name,y=0.98,color=colors[i],alpha=0.7)
PlotUtilities.save_twice(fig,final_out_path +".svg",
final_out_path + ".png",
subplots_adjust=dict(wspace=0.3,hspace=0.1,
left=0.1,bottom=0.1,
top=0.87))
示例5: make_main_figure
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def make_main_figure(output_path,trials):
"""
creates the 'main' timing figure (for use in the paper)
Args:
output_path: where to save the file
trials: the pickled timing trials information
"""
# make the figure for the presentation
fig = PlotUtilities.figure(figsize=(6,3))
_main_figure(trials)
plt.xlim([-1,3])
PlotUtilities.savefig(fig,output_path.replace(".pdf","_pres.pdf"))
# make the figure for the paper
fig = PlotUtilities.figure(figsize=(8,3))
_main_figure(trials)
PlotUtilities.label_tom(fig,loc=(-0.05,1))
PlotUtilities.save_twice(fig,output_path + ".png",output_path + ".svg")
示例6: make_detalied_plots
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [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(" ","_"))
示例7: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(base="./"):
"""
"""
out_base = base
data_file = "../FigurePerformance_CS/data/Scores.pkl"
force=False
events_off = CheckpointUtilities.getCheckpoint("cache_dist.pkl",
dist_values,force,
data_file)
max_with_error = 0
min_with_error = np.inf
# get the bounds
for i,(args,x,name) in enumerate(events_off):
max_with_error = max(max_with_error,max(args))
min_with_error = min(min_with_error,min(args))
ylim = [min_with_error/2,max_with_error*2]
# plot everything
fig = PlotUtilities.figure((16,8))
n_cols = 3
parameters = ["FEATHER probability","OpenFovea sensitivity",
"Scientific Python minimum SNR"]
markers = Plotting.algorithm_markers()
colors = Plotting.algorithm_colors()
for i,(args,x,name) in enumerate(events_off):
first = (i == 0)
param = parameters[i]
xlabel = "Tuning Parameter\n({:s})".format(param)
ylabel = "" if not first else "BCC"
plt.subplot(1,n_cols,(i+1))
lazy_kwargs = dict(useLegend=first,
frameon=True)
plt.loglog(x,args,marker=markers[i],linestyle='-',color=colors[i],
markersize=7)
plot_name = Plotting.algorithm_title_dict()[name]
title = "Tuning curve for {:s}".format(plot_name)
PlotUtilities.lazyLabel(xlabel,ylabel,title,**lazy_kwargs)
PlotUtilities.tickAxisFont()
plt.ylim([min_with_error/2,max_with_error*2])
loc = (-0.10,1.025)
PlotUtilities.label_tom(fig,loc=loc)
PlotUtilities.savefig(fig,out_base + "tuning.pdf")
示例8: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(base="./"):
"""
"""
data_base = base + "data/"
out_fig = "ruptures.pdf"
subplots_adjust = dict(hspace=0.1)
# save out without the labels
fig = PlotUtilities.figure((6,8))
opts = [ [False,False],
[True,False],
[True,True]]
for i,opt_tmp in enumerate(opts):
fig = PlotUtilities.figure((6,8))
rupture_plot(data_base,*opt_tmp)
PlotUtilities.savefig(fig,
out_fig.replace(".pdf","_pres{:d}.pdf".format(i)),
subplots_adjust=subplots_adjust)
# save out with the labels
fig = PlotUtilities.figure((8,12))
rupture_plot(data_base)
PlotUtilities.label_tom(fig,loc=(-0.1,0.97))
PlotUtilities.savefig(fig,out_fig,subplots_adjust=subplots_adjust)
示例9: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
def run(base="./"):
"""
"""
out_base = base
data_file = base + "data/Scores.pkl"
force=False
metric_list = CheckpointUtilities.getCheckpoint(base + "cache.pkl",
Offline.get_metric_list,
force,data_file)
lim_load_max = [0,0]
lim_force_max = [0,0]
distance_limits = [0,0]
count_max = 0
distance_limits = []
coeffs_compare = []
# get the plotting limits
update_limits = Offline.update_limits
for m in metric_list:
lim_force_max = update_limits(m.lim_force,lim_force_max)
lim_load_max = update_limits(m.lim_load,lim_load_max,floor=1e-1)
count_max = max(m.counts,count_max)
distance_limits.append(m.distance_limit(True))
coeffs_compare.append(m.coefficients())
write_coeffs_file(out_base + "metric_table.tex",coeffs_compare)
distance_limits = [np.min(distance_limits),np.max(distance_limits)]
# POST: have limits...
# plot the best fold for each
out_names = []
colors_pred = algorithm_colors()
# make a giant figure, 3 rows (one per algorithm)
fig = PlotUtilities.figure(figsize=(7,8))
entire_figure = gridspec.GridSpec(3,1)
title_dict = Plotting.algorithm_title_dict()
for i,m in enumerate(metric_list):
x,name,true,pred = m.x_values,m.name,m.true,m.pred
best_param_idx = m.best_param_idx
out_learner_base = "{:s}{:s}".format(out_base,name)
color_pred = colors_pred[i]
# define the styles for the histogram
xlabel_histogram = r"Distance [x$_k$]" \
if (i == len(metric_list)-1) else ""
# get the distance information we'll need
distance_kw = Plotting.\
event_error_kwargs(m,color_pred=color_pred,
distance_limits=distance_limits,
xlabel=xlabel_histogram)
gs = gridspec.GridSpecFromSubplotSpec(2, 3, width_ratios=[2,2,1],
height_ratios=[2,1],
subplot_spec=entire_figure[i],
wspace=0.35,hspace=0.4)
# plot the metric plot
Plotting.rupture_plot(true,pred,
lim_plot_load=lim_load_max,
lim_plot_force=lim_force_max,
color_pred=color_pred,
count_limit=[0.5,count_max*5],use_legend=(i==0),
distance_histogram=distance_kw,gs=gs,
fig=fig)
PlotUtilities.title(title_dict[name],x=-2,y=3.85,color=color_pred,
alpha=1)
# individual plot labels
n_subplots = 5
n_categories = len(metric_list)
letters = string.uppercase[:n_categories]
letters = [ ["{:s}{:d}".format(s,n+1) for n in range(n_subplots)]
for s in letters]
flat_letters = [v for list_of_v in letters for v in list_of_v]
PlotUtilities.label_tom(fig,flat_letters,loc=(-0.22,1.14))
final_out_path = out_base + "landscape.pdf"
PlotUtilities.save_twice(fig,final_out_path + ".png",final_out_path +".svg",
subplots_adjust=dict(left=0.10,
hspace=0.4,
wspace=0.2,top=0.95))
示例10: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [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)
示例11: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [as 别名]
#.........这里部分代码省略.........
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]
idx = np.where( (fig4ab.time <= max_x_new) & (fig4ab.time >= min_x_new))
time = fig4ab.time[idx]
force = fig4ab.force[idx]
FEC_Plot._fec_base_plot(time,force,n_filter_points=200,
style_data=dict(color=color_equil,alpha=0.3,
linewidth=0.75))
ax_time.set_xlim(min_x_new,max_x_new)
ax_time.set_ylim(None,None)
unit_kwargs = dict(value_function =lambda x: x*1e6,fmt="{:.0f}")
unit_micro_s = PlotUtilities.upright_mu() + "m"
x_kwargs = dict(unit_kwargs=unit_kwargs,width=500e-6,unit=unit_micro_s)
y_font = copy.deepcopy(Scalebar.def_font_kwargs_y)
y_font['rotation'] = 90
y_kwargs = dict(height=10,unit="pN",font_kwargs=y_font)
Scalebar.crossed_x_and_y_relative(offset_x=0.5,offset_y=0.08,
x_kwargs=x_kwargs,
y_kwargs=y_kwargs,
ax=ax_time)
PlotUtilities.no_x_label(ax=ax_time)
PlotUtilities.no_y_label(ax=ax_time)
PlotUtilities.lazyLabel("Time","Force","")
velocity_annotate(ax=ax_time,v=0,color=color_equil)
# # figure 4C from the science paper -- the pfold energy landscape
fig4c = figure_recreation.save_output(base_re,"Fig4C.csv")
ax_equil = plt.subplot(top_spec[1,2])
# data is in kJ/mol, communication with hao, 2017-9-14
fig4c.energy /= 4.2
fig4c.energy_error /= 4.2
plt.errorbar(fig4c.x,fig4c.energy,fig4c.energy_error,color=color_equil,
marker='o',
mfc='w',zorder=0,markerfacecolor="None",capsize=2,elinewidth=1,
linewidth=1)
PlotUtilities.lazyLabel("Extension (nm)","Energy","")
x_kwargs = dict(unit_kwargs=dict(fmt="{:.1f}"),width=0.1,unit="nm")
y_font = copy.deepcopy(Scalebar.def_font_kwargs_y)
y_font['rotation'] = 90
y_kwargs = dict(unit_kwargs=dict(fmt="{:.1f}"),
height=0.5,unit="kcal/mol",font_kwargs=y_font)
Scalebar.crossed_x_and_y_relative(offset_x=0.22,offset_y=0.60,
x_kwargs=x_kwargs,
y_kwargs=y_kwargs,
ax=ax_equil)
# add in bell...
bell_mean = 0.64
bell_std = 0.09
x0,xf = ax_equil.get_xlim()
mean_x = bell_mean * (xf-x0) + x0
std_x = bell_std * (xf-x0)
color_bell = 'k'
plt.axvspan(mean_x-std_x,mean_x+std_x,color=color_bell,alpha=0.15)
plt.axvline(mean_x,color=color_bell,linestyle='--',zorder=0,alpha=0.7)
PlotUtilities.no_x_label(ax=ax_equil)
t = ax_equil.annotate(s=r"$\Delta x^{\ddag}_{\mathrm{Bell}}$",
xy=(0.4,0.3),color=color_bell,
xycoords="axes fraction")
PlotUtilities.no_y_label(ax=ax_equil)
loc_upper = [-0.05,1.05]
loc_lower = [-0.05,1.0]
loc = [loc_upper,loc_upper,loc_upper,
loc_lower,loc_lower,loc_lower]
PlotUtilities.label_tom(fig,loc=loc)
subplots_adjust = dict(hspace=0.07,wspace=0.15)
PlotUtilities.save_png_and_svg(fig,"diagram",
subplots_adjust=subplots_adjust)
示例12: get_supplemental_figure
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [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
示例13: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import label_tom [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()
input_directory = base + \
"4Patrick/CuratedData/Grants/2017-4-1-nih-myosin/igor/cropped"
files = GenUtilities.getAllFiles(input_directory,ext=".ibw")
# read all the ibw files in and cache them
images = []
func = PxpLoader.read_ibw_as_image
for i,f in enumerate(files):
cache_file = "./{:d}.pkl".format(i)
tmp = CheckpointUtilities.getCheckpoint(cache_file,func,False,f)
images.append(tmp)
# rotate the first image
example = images[0]
example.rotate(angle_degrees=-40,reshape=False)
pcts = [np.percentile(i.height_nm_rel(),[60,100]) for i in images]
vmin = np.min(pcts)
vmax = np.max(pcts)
n_plots = len(images)
width = 3.5*n_plots
fig,axes = plt.subplots(figsize=(width,3),nrows=1,ncols=n_plots)
ax = []
font_common=dict(fontname="Arial")
for i,image in enumerate(images):
ax = axes.flat[i]
range_plot_nanometers = 1000 * image.range_microns()
vmin_dict = dict(vmin=vmin,vmax=vmax)
im = ImageUtil.PlotImage(image,cmap=plt.cm.afmhot,fix_extent=False,
ax=ax,range_plot=range_plot_nanometers,
**vmin_dict)
fudge_x = 0.01
fudge_y = 0.005
bar_offset = 0.2
cax = fig.add_axes([0.91,bar_offset,0.03,(1-(bar_offset+fudge_y))])
cbar = fig.colorbar(im,ax=list(axes),cax=cax,ticks=[0,1,2,3])
label_prop = dict(size=14,family='sans-serif',weight="bold")
cbar.set_label(label="Height (nm)",**label_prop)
cbar.ax.minorticks_on()
cbar.ax.yaxis.set_minor_locator(AutoMinorLocator(2))
common_tick = dict(direction='in')
cbar.ax.tick_params(which='minor',length=5,width=1,**common_tick)
cbar.ax.tick_params(which='major',length=8,width=1.5,**common_tick)
# for some reason, need to reformat after the color bar
# get the region we want to crop (in pixels)
xlim = [ [100,400],[450,600]]
ylim = [ [50,350],[550,700]]
for i,(ax,image )in enumerate(zip(axes,images)):
PlotUtilities.FormatImageAxis(ax=ax)
pixel_size_meters = image.pixel_size_meters
pixel_size_nanometers = pixel_size_meters * 1e9
scalebar = ScaleBar(pixel_size_nanometers,'nm',box_alpha=0,
location=(1),color='w',length_fraction=0.3,
font_properties=label_prop)
ax.add_artist(scalebar)
ax.set_xlim(xlim[i])
ax.set_ylim(ylim[i])
subplots_adjust=dict(top=1-fudge_y,bottom=fudge_y,
left=fudge_y,right=0.9,
hspace=fudge_y,wspace=fudge_x)
axis_func = lambda x: x[:-1]
PlotUtilities.label_tom(fig,loc=(0.05,0.93),color='w',fontsize=15,
axis_func=axis_func,**font_common)
PlotUtilities.savefig(fig,"{:d}.png".format(i),tight=True,
subplots_adjust=subplots_adjust,close=False)
PlotUtilities.savefig(fig,"{:d}.svg".format(i),tight=True,
subplots_adjust=subplots_adjust)