在同一图上添加样本,不使用散景删除以前的样本

时间:2014-12-01 11:00:39

标签: python bokeh

我想通过样本在一个图表样本中绘制大数据。应将新采样的数据添加到同一图上的先前样本中。我已经尝试了下面的代码,但它没有按预期工作。它只显示当前样本;它不会显示以前的所有样本。知道如何使用散景吗?

import numpy as np
import time
from bokeh.plotting import *
from bokeh.session import Session
from random import randint
from bokeh.objects import GLyph,GridPlot, HoverTool  

output_notebook(url="default")
#output_notebook()

figure(x_range=[0,1000000],y_range=[0,100],plot_width=1000,plot_height=600,title="Hello World!")
hold()
xs = []
ys = []
x = []
y = []
for num in range(0,1000000):
    xs.append(num)
for num in range(0,1000000):
    ys.append(randint(0,100))
scatter(x, y, color='#33A02C', fill_color=None, size=8)
renderer = [r for r in curplot().renderers if isinstance(r, Glyph)][0]
ds = renderer.data_source
show()
i = 0
iteration = 0
last = len(xs)
sampleSize = 1000
while(iteration <= len(xs)/sampleSize):
    x = xs[i:i+sampleSize]
    y = ys[i:i+sampleSize]
    ds.data["x"] = x
    ds.data["y"] = y
    ds._dirty = True
    cursession().store_objects(ds)
    iteration = iteration + 1
    i = i + sampleSize

0 个答案:

没有答案