Question

I want to make a cluster style dendrogram in bokeh. I like this bokeh dot plot example, but i want to make lines curvy and show a cluster strcuture like this : http://bl.ocks.org/mbostock/4063570

here is code from dot plot from bokeh example:

import numpy as np
from bokeh.plotting import *
from bokeh.objects import Range1d

N = 4000

factors = ["a", "b", "c", "d", "e", "f", "g", "h"]
x0 = [0,0,0,0,0,0,0,0]
x =  [50, 40, 65, 10, 25, 37, 80, 60]

output_file("categorical.html", title="categorical.py example")

hold()

segment(x0, factors, x, factors, y_range=factors, x_range=Range1d(start=0, end=100), 
        line_width=2, line_color="green", tools="resize,previewsave", title="Dot Plot")
circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3, Name="categorical example")

figure()

show()  # open a browser

here is the output of bokeh dot plot

Any suggestion on how to make lines curvy and show the clustering relation like in dendrogram. This picture is shown just to show the idea of straight line with dot. actual target is to show the clustering relation of all lines coming from single point.

Was it helpful?

Solution 2

This is not impossible to render in Bokeh (as of 0.4.4) but there is no built-in support to help with graphs and graph layout yet. You would have to compute or use a library to compute the line points for the edges, etc. and then pass those to Bokeh. Graph support is on our roadmap but it will probably not be until later this year unless a complete PR gets dropped in our lap.

OTHER TIPS

In the meanwhile (four years later, 2018-08) we run Bokeh 0.13.0. As the answer above is not really satisfying I would like to point you to two bokeh based dendrogram implementations.

Daniel Russo's quantitative data based bokeh dendrogram implementation: https://russodanielp.github.io/plotting-a-heatmap-with-a-dendrogram-using-bokeh.html

cdendro, the bokehheat library's categorical data based bokeh dendrogram implementation: https://gitlab.com/biotransistor/bokehheat

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top