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 shape(self, height, yrange, rotated): g = rlg2mpl.Group() (X, Y, I) = (0, 1, 2) #scaled_axes = [[X, I], [I, Y]][rotated] scaled_axes = [[X, X], [Y, Y]][rotated] scaled_axes = [[X, Y], [X, Y]][rotated] trans = TransformScalePart(g.combined_transform, scaled_axes) a = CircleCollection([.5], edgecolors=self.cvalues, facecolors=self.cvalues, offsets=self.offsets, transOffset=g.combined_transform) g.add(a) a.set_transform(trans) return g