本文整理汇总了Python中GeneralUtil.python.PlotUtilities.ylabel方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.ylabel方法的具体用法?Python PlotUtilities.ylabel怎么用?Python PlotUtilities.ylabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.ylabel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_fec_cartoon
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [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)
示例2: helical_gallery_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [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)
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [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: rupture_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [as 别名]
#.........这里部分代码省略.........
bins_rupture = _bins_rupture_plot
if (bins_load is None):
bins_load = _bins_load_plot
if (lim_plot_load is None):
lim_plot_load = _lim_load_plot
if (lim_plot_force is None):
lim_plot_force = _lim_force_plot
if (distance_histogram is not None):
ax_hist = plt.subplot(gs[:,0])
histogram_event_distribution(**distance_histogram)
ax0 = subplot_f(gs[0,offset])
plot_true_and_predicted_ruptures(true,pred,**scatter_kwargs)
PlotUtilities.xlabel("")
plt.xlim(lim_plot_load)
plt.ylim(lim_plot_force)
PlotUtilities.title(title)
if (remove_ticks):
ax0.get_xaxis().set_ticklabels([])
ax1 =subplot_f(gs[0,offset+1])
hatch_true = true_hatch()
true_style_histogram = _histogram_true_style(color_true=color_true,
label="true")
pred_style_histogram = _histogram_predicted_style(color_pred=color_pred,
label="predicted")
# for the rupture force, we dont add the label
rupture_force_true_style = dict(**true_style_histogram)
rupture_force_true_style['label'] = None
rupture_force_pred_style = dict(**pred_style_histogram)
rupture_force_pred_style['label'] = None
rupture_force_histogram(pred,orientation='horizontal',bins=bins_rupture,
**rupture_force_pred_style)
rupture_force_histogram(true,orientation='horizontal',bins=bins_rupture,
**rupture_force_true_style)
PlotUtilities.lazyLabel("Count","","")
ax = plt.gca()
# push count to the top
ax.xaxis.tick_top()
ax.xaxis.set_label_position('top')
if (remove_ticks):
ax1.get_yaxis().set_ticklabels([])
if (count_limit is not None):
plt.xlim(count_limit)
plt.ylim(lim_plot_force)
plt.xscale('log')
ax4 = subplot_f(gs[1,offset])
n_pred,_,_ = loading_rate_histogram(pred,orientation='vertical',
bins=bins_load,
**pred_style_histogram)
n_true,_,_, = loading_rate_histogram(true,orientation='vertical',
bins=bins_load,**true_style_histogram)
if (count_limit is None and (len(n_pred) * len(n_true) > 0)):
max_n = np.max([n_pred,n_true])
count_limit = [0.5,max_n*10]
else:
count_limit = plt.ylim()
PlotUtilities.lazyLabel("loading rate (pN/s)","Count","",frameon=False,
loc='upper left',useLegend=use_legend)
plt.xscale('log')
plt.yscale('log')
plt.xlim(lim_plot_load)
plt.ylim(count_limit)
ax3 = subplot_f(gs[1,offset+1])
if (len(loading_pred) > 0):
coeffs = Analysis.\
bc_coeffs_load_force_2d(loading_true,loading_pred,bins_load,
ruptures_true,ruptures_pred,bins_rupture)
# just get the 2d (last one
coeffs = [1-coeffs[-1]]
else:
coeffs = [0]
labels_coeffs = [r"BCC"]
# add in the relative distance metrics, if the are here
if (distance_histogram is not None):
_,_,cat_relative_median,cat_relative_q,q = \
Offline.relative_and_absolute_median_and_q(**distance_histogram)
coeffs.append(cat_relative_q)
q_fmt = str(int(q))
labels_coeffs.append(r"P$_{" + q_fmt + "}$")
coeffs = np.array(coeffs)
# an infinite coefficient (or nan) is just one (worst possible)
coeffs[np.where(~np.isfinite(coeffs))] = 1
index = np.array([i for i in range(len(coeffs))])
bar_width = 0.5
rects1 = plt.bar(index, coeffs,alpha=0.3,color=color_pred)
label_func = lambda i,r: "{:.3g}".format(r.get_height())
y_func = lambda i,r: r.get_height()/2
PlotUtilities.autolabel(rects1,label_func=label_func,y_func=y_func,
fontsize=PlotUtilities.g_font_legend,
fontweight='bold')
plt.xticks(index, labels_coeffs,
rotation=0,fontsize=PlotUtilities.g_font_label)
PlotUtilities.ylabel("Metric")
PlotUtilities.tickAxisFont()
# push metric to the right
ax = plt.gca()
ax.yaxis.tick_right()
ax.yaxis.set_label_position('right')
ax.tick_params(axis=u'x', which=u'both',length=0)
plt.ylim([0,1])
示例5: make_metric_plot
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [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 ylabel [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: plot_landscape
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [as 别名]
def plot_landscape(data,xlim,kw_landscape=dict(),plot_derivative=True,
zero_q=True,
label_deltaG = PlotUtilities.variable_string("\Delta G")):
landscape_kcal_per_mol = data.mean_landscape_kcal_per_mol
landscape_kcal_per_mol -= min(landscape_kcal_per_mol)
std_landscape_kcal_per_mol = data.std_landscape_kcal_per_mol
extension_nm = data._extension_grid_nm
if (zero_q):
extension_nm -= min(extension_nm)
extension_aa = data.amino_acids_per_nm() * extension_nm
grad = lambda x: np.gradient(x)/(np.gradient(extension_aa))
delta_landscape_kcal_per_mol_per_amino_acid = grad(landscape_kcal_per_mol)
landscape_upper = landscape_kcal_per_mol+std_landscape_kcal_per_mol
landscape_lower =landscape_kcal_per_mol-std_landscape_kcal_per_mol
delta_landscape_kcal_per_mol_per_amino_acid = \
data.mean_delta_landscape_kcal_per_mol_per_AA
std_delta_landscape_kcal_per_mol_per_AA = \
data.std_delta_landscape_kcal_per_mol_per_AA
upper_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid+\
std_delta_landscape_kcal_per_mol_per_AA
lower_delta_landscape = delta_landscape_kcal_per_mol_per_amino_acid-\
std_delta_landscape_kcal_per_mol_per_AA
# make a second axis for the number of ammino acids
limits_delta = [min(delta_landscape_kcal_per_mol_per_amino_acid),
max(delta_landscape_kcal_per_mol_per_amino_acid)]
limits_energy = [min(landscape_kcal_per_mol),max(landscape_kcal_per_mol)]
units_energy_delta = label_deltaG + \
r" per AA (kcal/(mol $\cdot$ AA))"
units_energy = PlotUtilities.unit_string("\Delta G","kcal/mol")
difference_color = 'rebeccapurple'
landscape_color = kw_landscape['color']
if (plot_derivative):
PlotUtilities.lazyLabel("Extension (nm)",units_energy_delta,"")
PlotUtilities.ylabel(units_energy_delta,color=difference_color)
else:
PlotUtilities.lazyLabel("Extension (nm)","","")
PlotUtilities.ylabel(units_energy,color=landscape_color)
# the derivative goes on the main axis in this case...
if (plot_derivative):
ax_delta = plt.gca()
ax_2 = PlotUtilities.secondAxis(ax_delta,
label=units_energy,color=landscape_color,
limits=limits_energy,secondY =True,
tick_color=landscape_color)
ax_energy = ax_2
to_ret = ax_delta,ax_energy
else:
ax_energy = plt.gca()
ax_delta = None
to_ret = ax_energy
# filter the data if we need to
if (xlim is not None and xlim[1] is not None):
idx= np.where( (extension_nm > xlim[0]) & (extension_nm < xlim[1]))
else:
idx =np.arange(extension_nm.size)
# plot the landscape and its standard deviation
ax_energy.plot(extension_nm[idx],landscape_kcal_per_mol[idx],
label=label_deltaG,zorder=10,**kw_landscape)
ax_energy.fill_between(x=extension_nm[idx],
y1=landscape_lower[idx],
y2=landscape_upper[idx],
alpha=0.15,zorder=10,**kw_landscape)
# the energy y label should be rotated if it is on the right
rotation = -90
if plot_derivative:
kw_y = dict(rotation=-90,x=-0.3)
else:
kw_y = dict()
PlotUtilities.ylabel(ax=ax_energy,lab=units_energy,**kw_y)
# move the y label to the right slightly i we are using both axes
if plot_derivative:
ax_energy.yaxis.set_label_coords(1.2,0.5)
if (plot_derivative):
# plot the energy delta and its bounds, based on the bounds on the
# landscape
ax_delta.plot(extension_nm[idx],
delta_landscape_kcal_per_mol_per_amino_acid[idx],
color=difference_color,linestyle='-',linewidth=1.5)
PlotUtilities.color_axis_ticks(color=landscape_color,ax=ax_energy,
spine_name='right')
ax_delta.fill_between(x=extension_nm[idx],
y1=lower_delta_landscape[idx],
y2=upper_delta_landscape[idx],
alpha=0.15,color=difference_color)
return to_ret
示例8: get_supplemental_figure
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import ylabel [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