scipy-cluster生成的树状图未显示 [英] Dendrogram generated by scipy-cluster does not show

查看:127
本文介绍了scipy-cluster生成的树状图未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 scipy-cluster 在某些数据上生成分层聚类.作为应用程序的最后一步,我称 dendrogram 用于绘制聚类的函数.我正在使用内置的Python 2.6.1和该matplotlib软件包.该程序运行正常,但最后出现了Rocket Ship图标(据我所知,这是python GUI应用程序的启动器)并立即消失而无所事事.什么也没显示.如果在通话后添加"raw_input",它将永远在扩展坞中上下反弹.如果我从终端为matplotlib运行一个简单的示例应用程序,它将运行良好.有人对此有经验吗?

I am using scipy-cluster to generate a hierarchical clustering on some data. As a final step of the application, I call the dendrogram function to plot the clustering. I am running on Mac OS X Snow Leopard using the built-in Python 2.6.1 and this matplotlib package. The program runs fine, but at the end the Rocket Ship icon (as I understand, this is the launcher for GUI applications in python) shows up and vanishes immediately without doing anything. Nothing is shown. If I add a 'raw_input' after the call, it just bounces up and down in the dock forever. If I run a simple sample application for matplotlib from the terminal it runs fine. Does anyone have any experiences on this?

推荐答案

我在Ubuntu 10.04上遇到了同样的问题. 为了从ipython交互式控制台中显示图形,请使用"-pylab"开关启动它,以启用matplotlib的交互式使用:

I had the same issue on Ubuntu 10.04. In order to get graphics to display from ipython interactive console, start it with "-pylab" switch, which enables the interactive use of matplotlib:

ipython -pylab

要在独立脚本执行期间显示图形,请使用matplotlib.pyplot.show调用.这是hcluster主页上的示例,第一行和最后一行是此处的重要位:

To get your graphics to display during the execution of a standalone script, use matplotlib.pyplot.show call. Here's an example from hcluster homepage, the first and last line are the significant bits here:

from matplotlib.pyplot import show

from hcluster import pdist, linkage, dendrogram
import numpy
from numpy.random import rand

X = rand(10,100)
X[0:5,:] *= 2
Y = pdist(X)
Z = linkage(Y)
dendrogram(Z)

show()

这篇关于scipy-cluster生成的树状图未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆