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