本文整理汇总了Python中GeneralUtil.python.PlotUtilities.save_twice方法的典型用法代码示例。如果您正苦于以下问题:Python PlotUtilities.save_twice方法的具体用法?Python PlotUtilities.save_twice怎么用?Python PlotUtilities.save_twice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralUtil.python.PlotUtilities
的用法示例。
在下文中一共展示了PlotUtilities.save_twice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_twice [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))
示例2: make_main_figure
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_twice [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")
示例3: run
# 需要导入模块: from GeneralUtil.python import PlotUtilities [as 别名]
# 或者: from GeneralUtil.python.PlotUtilities import save_twice [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))