Advertisement
Guest User

Bokeh Plot: glyph refers to non-existent column_name

a guest
Mar 18th, 2018
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1.  
  2. # coding: utf-8
  3.  
  4. import math
  5.  
  6. from bokeh.io import show, output_file
  7. from bokeh.plotting import figure
  8. from bokeh.models import GraphRenderer, StaticLayoutProvider, Oval
  9. from bokeh.palettes import Spectral8
  10.  
  11. N = 8
  12. node_indices = list(range(N))
  13.  
  14. plot = figure(title="Graph Layout Demonstration", x_range=(-1.1,1.1), y_range=(-1.1,1.1),
  15.               plot_width=250, plot_height=250,
  16.               tools="", toolbar_location=None)
  17.  
  18. graph = GraphRenderer()
  19.  
  20. graph.node_renderer.glyph = Oval(height=0.1, width=0.2, fill_color="color")
  21. graph.node_renderer.data_source.data = dict(
  22.     index=node_indices,
  23.     color=Spectral8
  24.     )
  25. graph.node_renderer.data_source.name = "Node Renderer"
  26.  
  27. graph.edge_renderer.data_source.data = dict(
  28.     start=[0]*N,
  29.     end=node_indices)
  30. graph.edge_renderer.data_source.name = "Edge Renderer"
  31.  
  32. ### start of layout code
  33. circ = [i*2*math.pi/8 for i in node_indices]
  34. x = [math.cos(i) for i in circ]
  35. y = [math.sin(i) for i in circ]
  36.  
  37. graph_layout = dict(zip(node_indices, zip(x, y)))
  38. graph.layout_provider = StaticLayoutProvider(graph_layout=graph_layout)
  39.  
  40. plot.renderers.append(graph)
  41.  
  42. #output_file("graph.html")
  43. show(plot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement