Difference between revisions of "Bokeh: Plot Random Data dengan Axis Datetime"

From OnnoWiki
Jump to navigation Jump to search
(New page: import sys import time import socket import random import datetime from numpy import cumprod, linspace, random from bokeh.plotting import figure, output_server, show, cursession,...)
 
Line 7: Line 7:
 
  from numpy import cumprod, linspace, random
 
  from numpy import cumprod, linspace, random
 
  from bokeh.plotting import figure,  output_server, show, cursession, vplot, output_file
 
  from bokeh.plotting import figure,  output_server, show, cursession, vplot, output_file
 
+
 
  TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
 
  TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
 
  output_file("coba5.html")
 
  output_file("coba5.html")
Line 22: Line 22:
 
   y += [random.random()]
 
   y += [random.random()]
 
   time.sleep(0.01)
 
   time.sleep(0.01)
 
+
 
+
 
  p = figure(tools=TOOLS)
 
  p = figure(tools=TOOLS)
 
  p.line(x, y,  name='randomaja',color='#1F78B4',legend='Analog 1')
 
  p.line(x, y,  name='randomaja',color='#1F78B4',legend='Analog 1')
 
   
 
   
 
  show(p)
 
  show(p)

Revision as of 09:12, 30 November 2015

import sys
import time
import socket
import random
import datetime

from numpy import cumprod, linspace, random
from bokeh.plotting import figure,  output_server, show, cursession, vplot, output_file

TOOLS = "pan,wheel_zoom,box_zoom,reset,save"
output_file("coba5.html")

x = [0]
y = [0]
i = 0
n  = datetime.datetime.now()
x = ['%d.%d'%(n.minute*60+n.second,n.microsecond)]
y = [random.random()]
for i in xrange(1000):
  n  = datetime.datetime.now()
  x += ['%d.%d'%(n.minute*60+n.second,n.microsecond)]
  y += [random.random()]
  time.sleep(0.01)


p = figure(tools=TOOLS)
p.line(x, y,  name='randomaja',color='#1F78B4',legend='Analog 1')

show(p)