Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. from bokeh.plotting import figure, curdoc
  2. from bokeh.models import HoverTool, TapTool, BoxZoomTool, BoxSelectTool, PreviewSaveTool, ResetTool
  3. from bokeh.models.widgets import Panel, Tabs, TextInput, RadioGroup
  4. from bokeh.models import Range1d, LogAxis, LinearAxis
  5. from bokeh.client import push_session
  6. from bokeh.models.sources import ColumnDataSource
  7. from bokeh.io import vform, hplot
  8. from bokeh.palettes import Spectral11
  9.  
  10. import numpy as np
  11.  
  12. tabs = []
  13.  
  14. x = np.linspace(-2*np.pi, 2*np.pi, 200)
  15.  
  16. colour_list = Spectral11 #[(51, 153, 51) ,(153, 51, 51), (51, 51, 153), (153, 51,153 ), (153, 51, 51)]
  17.  
  18.  
  19.  
  20. y = 2*x**2 + 7/4.*x - 4
  21. w = 1/100.* x**3 - x**2 + 45*x + 4
  22.  
  23. a = ColumnDataSource(dict(x = x, y = y, label = ["Second degree equation"]*len(x)))
  24. b = ColumnDataSource(dict(x = x, y = w, label = ["Third degree equation"]*len(x)))
  25.  
  26. Tools = "pan,wheel_zoom,box_zoom,reset,hover,previewsave"
  27.  
  28. figure_obj = figure(plot_width = 1000, plot_height = 800, title = "these are polinominals", tools = Tools)
  29.  
  30. hover = figure_obj.select_one(HoverTool).tooltips = [("degree", "@label"), ("(x,y)", "($x, $y)") ]
  31. line_render_one = figure_obj.line("x", "y", source = a, line_width = 2, line_color = colour_list[3])
  32. line_render_two = figure_obj.line("x", "y", source = b, line_width = 2, line_color = colour_list[1])
  33. line_renders = [line_render_one, line_render_two]
  34.  
  35. session = push_session(curdoc())
  36. session.show()
  37. session.loop_until_closed()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement