本文整理汇总了Python中matplotlib.patches.Rectangle.text方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.text方法的具体用法?Python Rectangle.text怎么用?Python Rectangle.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Rectangle
的用法示例。
在下文中一共展示了Rectangle.text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onselect
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import text [as 别名]
def onselect(vmin, vmax):
if vmin == vmax:
# check if the user clicked on existing rectangle
for r in reversed(onselect.rects):
if r.get_x() <= vmin <= r.get_x() + r.get_width():
# delete the rectangle
r.text.remove()
onselect.rects.remove(r)
r.remove()
onselect.ax.figure.canvas.draw()
break
return
# find a frame index which have a smallest total RMSd
subset = onselect.data[vmin:vmax, vmin:vmax]
totals = np.sum(subset, axis=0)
mmrms = np.min(totals) / len(totals)
found = np.argmin(totals) + vmin
bboxprops = dict(
boxstyle='round',
facecolor='w',
linewidth=0,
alpha=0.5,
)
t = onselect.ax.text(
vmin + (vmax - vmin) / 2,
vmin + (vmax - vmin) / 2,
"RMSd: %.2f\nFrame: %d\nIn: %d-%d" % (mmrms, found, vmin, vmax),
fontsize=10,
va='center', ha='center',
color='k',
bbox=bboxprops,
)
r = Rectangle(
(vmin, vmin),
vmax-vmin, vmax-vmin,
alpha=0.5,
color=next(onselect.colors),
fill=False,
)
r.text = t
onselect.rects.append(r)
onselect.ax.add_patch(r)
onselect.ax.figure.canvas.draw()