MCPcopy
hub / github.com/jesolem/PCV / draw

Method draw

PCV/clustering/hcluster.py:34–53  ·  view source on GitHub ↗

Draw nodes recursively with image thumbnails for leaf nodes.

(self,draw,x,y,s,imlist,im)

Source from the content-addressed store, hash-verified

32 return max(self.left.get_depth(), self.right.get_depth()) + self.distance
33
34 def draw(self,draw,x,y,s,imlist,im):
35 """ Draw nodes recursively with image
36 thumbnails for leaf nodes. """
37
38 h1 = int(self.left.get_height()*20 / 2)
39 h2 = int(self.right.get_height()*20 /2)
40 top = y-(h1+h2)
41 bottom = y+(h1+h2)
42
43 # vertical line to children
44 draw.line((x,top+h1,x,bottom-h2),fill=(0,0,0))
45
46 # horizontal lines
47 ll = self.distance*s
48 draw.line((x,top+h1,x+ll,top+h1),fill=(0,0,0))
49 draw.line((x,bottom-h2,x+ll,bottom-h2),fill=(0,0,0))
50
51 # draw left and right child nodes recursively
52 self.left.draw(draw,x+ll,top+h1,s,imlist,im)
53 self.right.draw(draw,x+ll,bottom-h2,s,imlist,im)
54
55
56class ClusterLeafNode(object):

Callers 1

draw_dendrogramFunction · 0.45

Calls 1

get_heightMethod · 0.45

Tested by

no test coverage detected