Guest User

Untitled

a guest
May 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. from bokeh.models import HoverTool
  2. from bokeh.plotting import figure, show, output_file, ColumnDataSource
  3. from bokeh.layouts import gridplot
  4. from bokeh.palettes import magma
  5.  
  6. def plot(u, descs=index_to_interesting_subject):
  7. source = ColumnDataSource(data=dict(
  8. x1=u[:, 0],
  9. x2=u[:, 1],
  10. x3=u[:, 2],
  11. x4=u[:, 3],
  12. desc=descs,
  13. ))
  14.  
  15. hover = HoverTool(tooltips=[
  16. ("index", "$index"),
  17. ("desc", "@desc"),
  18. ])
  19.  
  20. def plot_it(x, y):
  21. p = figure(plot_width=250, plot_height=250, tools=[hover])
  22. p.scatter(
  23. x, y,
  24. size=5,
  25. source=source,
  26. line_color=None,
  27. alpha=0.8,
  28. )
  29. return p
  30.  
  31. p12 = plot_it('x2', 'x1')
  32. p13 = plot_it('x3', 'x1')
  33. p14 = plot_it('x4', 'x1')
  34.  
  35. p23 = plot_it('x3', 'x2')
  36. p24 = plot_it('x4', 'x2')
  37.  
  38. p34 = plot_it('x4', 'x3')
  39.  
  40. grid = gridplot([[p12, p13, p14], [None, p23, p24], [None, None, p34]])
  41.  
  42. output_file("word_doc.html", title="word-doc")
  43.  
  44. show(grid)
  45.  
  46. plot(u)
Add Comment
Please, Sign In to add comment