[bokeh] Hover over nodes in Network Graph failing

Hi,

I'd like to try to run your example code to see if I can help figure out what is the matter, but I notice that it is missing imports and functions. If you post a complete example that can be run as-is I am happy to try to help more specifically. Otherwise my only offhand suggestion is not to set the .data of one CDS from the .data of another (as you are doing). The .data attribute is a specially instrumented dict and sone from another might cause problems. Every example we ever show has the form:

  source.data = dict(....) # not source.data = other_source.data

And I would recommend following that pattern.

Thanks,

Bryan

···

On Sep 9, 2017, at 16:15, [email protected] wrote:

Hi all,

I've seemed to have noticed a pretty frustrating issue with Bokeh 0.12.7 (the latest pip version). Essentially, I would like to show some data when the cursor hovers over a node but I keep getting a '???' which indicates that the data can not be found at that index. The thing is, I have no idea why - the data is there and it is correctly indexed.

The thing that seems to indicate that this may be a Bokeh issue is that I get a warning in my Jupyter Notebook:
E-1001 (BAD_COLUMN_NAME): Glyph refers to nonexistent column name: fill_color [renderer: GlyphRenderer(id='f12389b5-5864-48e9-9248-1c34cf5c3dc4', ...)]

Obviously, this is odd because fill_color is definitely in the data source so it is there. Also, the nodes are correctly coloured which just adds to my confusion.

Would appreciate any help if possible! Please find an example image of what I see below:

The code is below - I cannibalised the from_networkx function just to try and identify the issue but that function seems to be working perfectly (and is v. simple)

pos = graphviz_layout(G, prog='twopi', root = root_node)
max_x = max([i[1][0] for i in pos.items()])
min_x = min([i[1][0] for i in pos.items()])
max_y = max([i[1][1] for i in pos.items()])
min_y = min([i[1][1] for i in pos.items()])

hover = bokeh.models.tools.HoverTool(tooltips=[("idx", "$index"), ("index", "@keys"), ("Author","@names"), ("Source","@papers")])
plot = bokeh.plotting.figure(plot_width=600, plot_height=600, x_range=bokeh.models.ranges.Range1d(min_x - 20,max_x + 20),\
                             y_range=bokeh.models.ranges.Range1d(min_y - 20,max_y + 20),\
                             tools=[hover, bokeh.models.tools.PanTool(), bokeh.models.tools.WheelZoomTool(), \
                                    bokeh.models.tools.TapTool(), bokeh.models.tools.ResetTool()], \
                             title="Network Graph for " + search.title()
                            )

nodes = G.nodes()
edges = G.edges()
edges_start = [edge[0] for edge in edges]
edges_end = [edge[1] for edge in edges]
node_source = ColumnDataSource(data=dict(index= nodes,
                                         fill_color = colours,
                                         author = names,
                                         source = papers))
edge_source = ColumnDataSource(data=dict(
                                        start=edges_start,
                                        end=edges_end
))
plot.xaxis.visible = False
plot.xgrid.visible = False
plot.yaxis.visible = False
plot.ygrid.visible = False

graph_renderer = bokeh.models.renderers.GraphRenderer()
graph_renderer.node_renderer.data_source.data = node_source.data
graph_renderer.node_renderer.glyph = bokeh.models.Circle(size=15, fill_color="fill_color")
graph_renderer.node_renderer.selection_glyph = bokeh.models.Circle(size=15, fill_color=Spectral8[2])
graph_renderer.edge_renderer.data_source.data = edge_source.data
graph_renderer.edge_renderer.glyph = bokeh.models.MultiLine(line_color="#CCCCCC", line_alpha=0.8, line_width=5)
graph_renderer.edge_renderer.selection_glyph = bokeh.models.MultiLine(line_color=Spectral4[2], line_width=5)
graph_renderer.layout_provider = StaticLayoutProvider(graph_layout=pos)

graph_renderer.selection_policy = NodesAndLinkedEdges()

plot.renderers.append(graph_renderer)
show(plot)

Thanks!

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e4d864b2-326d-4f28-a2ed-1d754811a098%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for getting back to me. It turns out, there was something wrong with my Jupyter Notebook instance - restarting the kernel and running the code as above again fixed my problem. Not sure what happened but I will let you know if this happens to me again.

Thanks for the suggestion!

Best wishes,

Imran

···

On Saturday, September 9, 2017 at 10:21:13 PM UTC+1, Bryan Van de ven wrote:

Hi,

I’d like to try to run your example code to see if I can help figure out what is the matter, but I notice that it is missing imports and functions. If you post a complete example that can be run as-is I am happy to try to help more specifically. Otherwise my only offhand suggestion is not to set the .data of one CDS from the .data of another (as you are doing). The .data attribute is a specially instrumented dict and sone from another might cause problems. Every example we ever show has the form:

    source.data = dict(....)  # not source.data = other_source.data

And I would recommend following that pattern.

Thanks,

Bryan

On Sep 9, 2017, at 16:15, [email protected] wrote:

Hi all,

I’ve seemed to have noticed a pretty frustrating issue with Bokeh 0.12.7 (the latest pip version). Essentially, I would like to show some data when the cursor hovers over a node but I keep getting a ‘???’ which indicates that the data can not be found at that index. The thing is, I have no idea why - the data is there and it is correctly indexed.

The thing that seems to indicate that this may be a Bokeh issue is that I get a warning in my Jupyter Notebook:
E-1001 (BAD_COLUMN_NAME): Glyph refers to nonexistent column name: fill_color [renderer: GlyphRenderer(id=‘f12389b5-5864-48e9-9248-1c34cf5c3dc4’, …)]

Obviously, this is odd because fill_color is definitely in the data source so it is there. Also, the nodes are correctly coloured which just adds to my confusion.

Would appreciate any help if possible! Please find an example image of what I see below:

The code is below - I cannibalised the from_networkx function just to try and identify the issue but that function seems to be working perfectly (and is v. simple)

pos = graphviz_layout(G, prog=‘twopi’, root = root_node)

max_x = max([i[1][0] for i in pos.items()])

min_x = min([i[1][0] for i in pos.items()])

max_y = max([i[1][1] for i in pos.items()])

min_y = min([i[1][1] for i in pos.items()])

hover = bokeh.models.tools.HoverTool(tooltips=[(“idx”, “$index”), (“index”, “@keys”), (“Author”,"@names"), (“Source”,"@papers")])

plot = bokeh.plotting.figure(plot_width=600, plot_height=600, x_range=bokeh.models.ranges.Range1d(min_x - 20,max_x + 20),\

                         y_range=bokeh.models.ranges.Range1d(min_y - 20,max_y + 20),\
                         tools=[hover, bokeh.models.tools.PanTool(), bokeh.models.tools.WheelZoomTool(), \
                                bokeh.models.tools.TapTool(), bokeh.models.tools.ResetTool()], \
                         title="Network Graph for " + search.title()
                        )

nodes = G.nodes()

edges = G.edges()

edges_start = [edge[0] for edge in edges]

edges_end = [edge[1] for edge in edges]

node_source = ColumnDataSource(data=dict(index= nodes,
fill_color = colours,
author = names,
source = papers))

edge_source = ColumnDataSource(data=dict(

                                    start=edges_start,
                                    end=edges_end

))

plot.xaxis.visible = False

plot.xgrid.visible = False

plot.yaxis.visible = False

plot.ygrid.visible = False

graph_renderer = bokeh.models.renderers.GraphRenderer()

graph_renderer.node_renderer.data_source.data = node_source.data

graph_renderer.node_renderer.glyph = bokeh.models.Circle(size=15, fill_color=“fill_color”)

graph_renderer.node_renderer.selection_glyph = bokeh.models.Circle(size=15, fill_color=Spectral8[2])

graph_renderer.edge_renderer.data_source.data = edge_source.data

graph_renderer.edge_renderer.glyph = bokeh.models.MultiLine(line_color="#CCCCCC", line_alpha=0.8, line_width=5)

graph_renderer.edge_renderer.selection_glyph = bokeh.models.MultiLine(line_color=Spectral4[2], line_width=5)

graph_renderer.layout_provider = StaticLayoutProvider(graph_layout=pos)

graph_renderer.selection_policy = NodesAndLinkedEdges()

plot.renderers.append(graph_renderer)

show(plot)

Thanks!


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e4d864b2-326d-4f28-a2ed-1d754811a098%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.