Search code examples
pythongraphvisualizationbokehchord-diagram

Change palette for Chord Diagram in Bokeh


I am using the Bokeh library to generate a chord diagram. The diagram itself generates more-or-less just fine, but I'm having difficulty figuring out how to change the palette. As far as I can gather, most charts in Bokeh can have an optional palette argument, but adding this doesn't change the palette. Am I missing something?

import bokeh
from bokeh.charts import Chord
from bokeh.io import show, output_file
from bokeh.palettes import inferno

chord_diagram = Chord(forchord, source='nameA', target='nameB', palette= inferno(256))
show(chord_diagram)

If some data would help:

nameA_lst = ['Creb5','Creb5','JDP2(var.2)','JDP2(var.2)',
             'Creb5','JDP2(var.2)','ATF7','ATF','ATF7','Creb5']
nameB_lst = ['STAT3','STAT1','STAT3','STAT1','Stat4',
             'Stat4','STAT3','STAT1','Stat4','Stat5a::Stat5b']
forchord = pd.DataFrame({'nameA': nameA_lst, 'nameB': nameB_lst})
forchord.head()
    nameA   nameB
0   Creb5   STAT3
1   Creb5   STAT1
2   JDP2(var.2) STAT3
3   JDP2(var.2) STAT1
4   Creb5   Stat4

Solution

  • Chord doesn't use palette, it use color wheel like this:

    enter image description here