I am using scipy-cluster in my application. It provides a function to plot a dendrogram of the hierarchical cluster tree. Looking at the source I find that it eventually plots the dendrogram by calling draw_if_interactive
. As one would expect, this works fine in an interactive session, but when I run the script non-interactively, a window pops up and immediately vanishes again (I have configured matplotlib to use the macosx
-backend). I need a way to either make my application wait until the user closes the window showing the plot, or to make it render directly into a file (which actually I would prefer). Again, the problem is, that I cannot modify the code that generates the plot, so the solution will probably involve some configuration settings for matplotlib or something like that.
EDIT: I added my current workaround as an answer, so others may use it. Since it is very ugly, I will leave this question open hoping for someone to come up with a better solution.