0

Giving he following setting:

Python = 3.11
Holoviews = 1.17.0
Bokeh = 3.2.1

and df:

source target count Band 1 Band 1 2742 Band 1 Band 1 5976 Band 1 Band 1 7731 Band 1 Band 2 31831 Band 2 Band 2 38582 Band 2 Band 2 48177 Band 2 Band 3 53914 Band 2 Band 3 73824 Band 3 Band 3 208555 Band 3 Band 4 to 20 233206 Band 3 Band 4 to 20 274906 Band 3 Band 4 to 20 483953

and the code

import holoviews as hv
from holoviews import opts, dim
hv.extension('bokeh')
from bokeh.themes.theme import Theme
theme = Theme(
        json={
    'attrs' : {
        
        "text":{
            "text_font" : "arial",
        }}
    })    

hv.extension('bokeh')
hv.renderer('bokeh').theme = theme

sankey1 = hv.Sankey(df, kdims=["source", "target"], vdims=["count"])

coldict = { "Band 1": "#264424",
           "Band 1 ": "#264424",
           "Band 2":"#D38663",
           "Band 2 ":"#D38663",
           "Band 3":"#7D9149",
           "Band 3 ":"#7D9149",
           "Band 4 to 20": "#b3bbb2"          
    
}

## Modifying Default Chart Options
sp = sankey1.opts(cmap=coldict,
             label_position='outer',
             edge_color='source', edge_line_width=0,
             node_alpha=1.0, node_width=40, node_sort=False,
             width=1000, height=800, bgcolor="snow",show_values=False,node_color = "source",
             title="Population Migration between New Zealand and Other Continents")

Plotting the Sankey work fine.

However when it add

txt = hv.Text(200,300,"some text")

sp * txt

throws an error the ends with

File ~\AppData\Local\anaconda3\envs\viz\Lib\site-packages\holoviews\plotting\bokeh\sankey.py:238, in SankeyPlot.get_extents(self, element, ranges, range_type, **kwargs)
    236 xdim, ydim = element.nodes.kdims[:2]
    237 xpad = .05 if self.label_index is None else 0.25
--> 238 x0, x1 = ranges[xdim.name][range_type]
    239 y0, y1 = ranges[ydim.name][range_type]
    240 xdiff = (x1-x0)

KeyError: None

I tried to run the sample in Holoviews documentation https://holoviews.org/reference/elements/bokeh/Text.html

And it works.

And sp + txt works as well.

I suppose the issue is with the Sankey module but I can't figure out where is the issue. Any help will be very very much appreciated.

Torakiki
  • 45
  • 6

0 Answers0