Is there a way to plot dendrogram?

plotting

#1

Hierarchical clustering is quite simple in Julia by using hclust() in the Clustering package,
but plotting the result in Julia does not seem to be straightforward for me as in Python.
(see https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/#Perform-the-Hierarchical-Clustering)

Grateful to any suggestion from you.


#2

Not that I know of - but this would be an excellent contribution to a package like PlotRecipes, or as a plotting recipe in Clustering itself if they are happy to have it there.


#3

PlotRecipes already has recipes for plotting graph-like objects - it may be possible to create a plot recipe that uses this existing functionality.


#4

You might want to look at https://github.com/jangevaare/PhyloTrees.jl. There’s an example in the Plots docs: https://juliaplots.github.io/ecosystem/

Even if this doesn’t directly solve your problem, you might be able to get ideas from it.


#5

I often do my computation in Julia but then use the PyCall package to call a mature Python visualization routine on that data. PyCall is really easy to use.


#6

eg,

using PyCall
using PyPlot
@pyimport scipy.cluster.hierarchy as hierarchy
hierarchy.dendrogram([0 1 .7 2])


#7

The linkage function in Scipy follows MATLAB-style output while hclust() in Clustering.jl follows R-style one.

Since MATLAB-style output is more compatible in both suggestions above, I hope that the hclust() in Clustering.jl will be revised sometime (Sorry if the JuliaStat Project favors R-Style). Changing the output format itself is not difficult but a bit bothering for someone :slight_smile:


#8

Kescobo have a nice implementation, just was not merged. It works directly with Hclust type.