在python中手动绘制树状图

在python中手动绘制树状图

问题描述:

我已经实现了一种算法来解决图形中的聚类问题.我使用python库"python-graph"来表示图.现在,在计算的每个步骤(算法是迭代的)中,我都必须绘制部分树状图.实际上,从原始图形开始计算聚类的意义上说,该算法是分裂性的.现在,我不知道该用什么来绘制树状图(有人建议使用PIL,但我正在寻找简单的方法,而且我不知道如何使用PIL)...用它做图吗?

I have implemented an algorithm to solve the problem of clustering in a graph. I used the python library "python-graph" to represent the graph. Now, at each step of my computation (the algorithm is iterative) I have to draw a part of the dendrogram. In fact, the algorithm is divisive, in the sense that starting from the original graph calculates the clusters. Now, I don't know what to use to draw the dendrogram (someone suggested PIL, but I'm looking for something easy and I don't know how to use PIL)... can you suggest something and show me how to do plot with it?

注意:我读了其他问题,但是所有内容似乎都使用了自动计算聚类的方法……这不是我想要的:我需要手动绘制树状图或至少找到一种表示方法计算要绘制的聚类.

Note: I read other questions but everything seems to use methods that use automatic computation of the clusters... this is not what I'm looking for: I need to manually draw the dendrogram or at least find a way to represent the clusters computed to be drawn.

谢谢!

实现此处,这个简单的实现将为您提供帮助继续前进.

Code to implement scipy dendrogram can be found here and this simple implementation will help you to move on.