Dendrogram generated by scipy-cluster does not show

前端 未结 2 1136
無奈伤痛
無奈伤痛 2021-02-05 16:40

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 runn

2条回答
  •  我在风中等你
    2021-02-05 16:55

    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
    

    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()
    

提交回复
热议问题