Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dendrogram generated by scipy-cluster does not show

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?

like image 496
Björn Pollex Avatar asked Jun 03 '10 16:06

Björn Pollex


People also ask

How do you display a dendrogram?

In addition to creating a plot, the dendrogram function returns a dictionary (they call it R in the docs) containing several lists. The leaf_label_func you create must take in a value from R["leaves"] and return the desired label. The easiest way to set labels is to run dendrogram twice.

What does a cluster dendrogram show?

A dendrogram is a diagram that shows the hierarchical relationship between objects. It is most commonly created as an output from hierarchical clustering. The main use of a dendrogram is to work out the best way to allocate objects to clusters.


1 Answers

I have been facing the same problem. You can use one of the below methods

  1. Use plt.show() : use plt.show() after dedogram, this will show the plot using plt.show

  2. Use %matplotlib inline intially in jupyter notebook. this will show the plot after execution. Using matplotlib inline

like image 183
Siddharth Singh Avatar answered Oct 05 '22 08:10

Siddharth Singh