def add_circles_branches(treeplot, nodes, distances, colors="g", size=15,xoff=0,yoff=0,vis=True): """ Draw circles on branches Args: nodes: A node object or list of Node objects or label or list of labels distances: Float or list of floats indicating the distance from the **parent** node the branch should be drawn on. colors: Str or list of strs. Colors of the circles. Optional, defaults to 'g' (green) size (float): Size of the circles. Optional, defaults to 15 xoff, yoff (float): X and Y offset. Optional, defaults to 0. """ points = xy(treeplot, nodes) coords = [(x[0]-distances[i],x[1]) for i,x in enumerate(points)] trans = offset_copy( treeplot.transData, fig=treeplot.figure, x=xoff, y=yoff, units='points' ) col = CircleCollection( sizes=(pi*size*size*0.25,), offsets=coords, facecolors=colors, transOffset=trans, edgecolors='none', zorder=1 ) col.set_visible(vis) treeplot.add_collection(col) treeplot.figure.canvas.draw_idle()
def add_circles(treeplot, nodes, colors="g", size=15, xoff=0, yoff=0, vis=True): """ Draw circles on plot Args: nodes: A node object or list of Node objects or label or list of labels colors: Str or list of strs. Colors of the circles. Optional, defaults to 'g' (green) size (float): Size of the circles. Optional, defaults to 15 xoff, yoff (float): X and Y offset. Optional, defaults to 0. """ points = xy(treeplot, nodes) trans = offset_copy( treeplot.transData, fig=treeplot.figure, x=xoff, y=yoff, units='points' ) col = CircleCollection( sizes=(pi*size*size*0.25,), offsets=points, facecolors=colors, transOffset=trans, edgecolors='none', zorder=1 ) col.set_visible(vis) treeplot.add_collection(col) treeplot.figure.canvas.draw_idle()
def add_circles(treeplot, nodes, colors="g", size=15, xoff=0, yoff=0, vis=True): """ Draw circles on plot at nodes Args: nodes: A node object or list of Node objects or label or list of labels colors: Str or list of strs. Colors of the circles. Optional, defaults to 'g' (green) size (float): Size of the circles. Optional, defaults to 15 xoff, yoff (float): X and Y offset. Optional, defaults to 0. """ points = xy(treeplot, nodes) trans = offset_copy( treeplot.transData, fig=treeplot.figure, x=xoff, y=yoff, units='points' ) col = CircleCollection( sizes=(pi*size*size*0.25,), offsets=points, facecolors=colors, transOffset=trans, edgecolors='none', zorder=1 ) col.set_visible(vis) treeplot.add_collection(col) treeplot.figure.canvas.draw_idle()