Bokeh: Plot Random Data dengan Axis Datetime

From OnnoWiki
Revision as of 09:11, 30 November 2015 by Onnowpurbo (talk | contribs) (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,...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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)