Adding samples on the same figure with out deleting the previous samples using bokeh

I want to plot large data in one graph sample by sample. The newly sampled data should be added to the previous samples on the same plot. I have tried the code below, but it doesn’t work as intended. It only displays the current sample; it does not display all the previous samples. Any idea how to do it using 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

Hi Habtamu,

I think I just answered a similar question here:

https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/8i01xwr1t0c

The short answer is that there is currently not a way to incrementally patch or update a data source but that we will prioritize this after the upcoming 0.7 release.

Thanks,

Bryan

···

On Monday, December 1, 2014 7:09:53 AM UTC-6, Habtamu Aboma wrote:

I want to plot large data in one graph sample by sample. The newly sampled data should be added to the previous samples on the same plot. I have tried the code below, but it doesn’t work as intended. It only displays the current sample; it does not display all the previous samples. Any idea how to do it using 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

Hi Bryan,

Thank you very much for your response.

Habtamu

···

On Mon, Dec 1, 2014 at 6:42 PM, Bryan Van de ven [email protected] wrote:

Hi Habtamu,

I think I just answered a similar question here:

https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/8i01xwr1t0c

The short answer is that there is currently not a way to incrementally patch or update a data source but that we will prioritize this after the upcoming 0.7 release.

Thanks,

Bryan

On Monday, December 1, 2014 7:09:53 AM UTC-6, Habtamu Aboma wrote:

I want to plot large data in one graph sample by sample. The newly sampled data should be added to the previous samples on the same plot. I have tried the code below, but it doesn’t work as intended. It only displays the current sample; it does not display all the previous samples. Any idea how to do it using 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

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/74f48967-33b6-41ec-9a72-d9a8fe052ab0%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.