def draw_dendrogram(node, imlist, filename='clusters.jpg'):
 rows = (node.get_height() * 20)
 cols = 1200
 s = (float((cols - 150)) / node.get_depth())
 im = Image.new('RGB', (cols, rows), (255, 255, 255))
 draw = ImageDraw.Draw(im)
 draw.line((0, (rows / 2), 20, (rows / 2)), fill=(0, 0, 0))
 node.draw(draw, 20, (rows / 2), s, imlist, im)
 im.save(filename)
 im.show()

def draw_dendrogram ( node , imlist , filename = 'clusters.jpg' ) : rows = ( node . get_height ( ) * 20 ) cols = 1200 s = ( float ( ( cols - 150 ) ) / node . get_depth ( ) ) im = Image . new ( 'RGB' , ( cols , rows ) , ( 255 , 255 , 255 ) ) draw = ImageDraw . Draw ( im ) draw . line ( ( 0 , ( rows / 2 ) , 20 , ( rows / 2 ) ) , fill = ( 0 , 0 , 0 ) ) node . draw ( draw , 20 , ( rows / 2 ) , s , imlist , im ) im . save ( filename ) im . show ( )
draw a cluster dendrogram and save to a file .