1

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

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
4

0 回答 0