本文整理汇总了Python中matplotlib.collections.RegularPolyCollection.set_visible方法的典型用法代码示例。如果您正苦于以下问题:Python RegularPolyCollection.set_visible方法的具体用法?Python RegularPolyCollection.set_visible怎么用?Python RegularPolyCollection.set_visible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.RegularPolyCollection
的用法示例。
在下文中一共展示了RegularPolyCollection.set_visible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_squares
# 需要导入模块: from matplotlib.collections import RegularPolyCollection [as 别名]
# 或者: from matplotlib.collections.RegularPolyCollection import set_visible [as 别名]
def add_squares(treeplot, nodes, colors='r', size=15, xoff=0, yoff=0, alpha=1.0,
vis=True):
"""
Draw a square at given node
Args:
p: A node or list of nodes or string or list of strings
colors: Str or list of strs. Colors of squares to be drawn.
Optional, defaults to 'r' (red)
size (float): Size of the squares. Optional, defaults to 15
xoff, yoff (float): Offset for x and y dimensions. Optional,
defaults to 0.
alpha (float): between 0 and 1. Alpha transparency of squares.
Optional, defaults to 1 (fully opaque)
zorder (int): The drawing order. Higher numbers appear on top
of lower numbers. Optional, defaults to 1000.
"""
points = xy(treeplot, nodes)
trans = offset_copy(
treeplot.transData, fig=treeplot.figure, x=xoff, y=yoff, units='points')
col = RegularPolyCollection(
numsides=4, rotation=pi*0.25, sizes=(size*size,),
offsets=points, facecolors=colors, transOffset=trans,
edgecolors='none', alpha=alpha, zorder=1
)
col.set_visible(vis)
treeplot.add_collection(col)
treeplot.figure.canvas.draw_idle()