Is there a way to refresh an entire plot with new data ALL at once?

Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.

Hi,

Unless I am misunderstanding, this is exactly how most of the examples under examples/app (or that are deployed at demo.bokehplots.com) work. They update all of a column data source's .data property at once. Or do you mean something else?

Thanks,

Bryan

···

On Jan 19, 2017, at 10:33 AM, Eugene Cheung <[email protected]> wrote:

Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.

--
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/0687ef84-fa52-4a4e-9c6d-0af484792ce1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?

···

On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:

Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.

Hi Eugene,

I'm still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

···

On Jan 19, 2017, at 11:23 AM, Eugene Cheung <[email protected]> wrote:

Hi Bryan,

Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?

On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:
Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.

--
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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi very sorry if I am missing something very obvious that was in the examples… but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.

···

On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:

Hi Eugene,

I’m still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

On Jan 19, 2017, at 11:23 AM, Eugene Cheung [email protected] wrote:

Hi Bryan,

Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?

On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:

Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.


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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.

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

Right now i am still using the doc.add_next_tick_callback but just updating the entire source. Anybody know if this is the right way to do it?

YVal = 200

XVal = 0

source = ColumnDataSource(data=dict(x=, y=))

doc = curdoc()

def notify():

time.sleep(5)

doc.add_next_tick_callback(partial(update))

def update():

print “i am here in update”

global source

s = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[20,20,20,20,20]))

source.data.update(s.data)

p = figure(y_range=[0,100], plot_width=1000)

source = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[10,10,10,10,10]))

p.line(x=‘x’, y=‘y’, source=source)

doc.add_root§

thread = Thread(target = notify)

thread.start()

···

On Thursday, 19 January 2017 13:23:28 UTC-5, Eugene Cheung wrote:

Hi very sorry if I am missing something very obvious that was in the examples… but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.

On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:

Hi Eugene,

I’m still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

On Jan 19, 2017, at 11:23 AM, Eugene Cheung [email protected] wrote:

Hi Bryan,

Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?

On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:

Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.


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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.

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

Hi Eugene,

I just don't understand what kind of event you are talking about, or why it would be different. You can set:

  source.data = some_new_data_dict

at pretty much any time you want, in response to any event you want, and that will update a plot. This happens automatically. If you change the value of .data, the plot will update, there is not separate event you need to trigger explicitly.

Pretty much the *only* caveat is if you are using "unlocked" callbacks, and threads, etc., then you have to use a helper function that is passed to add_next_tick_callback, to safely do the real updates on any bokeh models there (e.g. the the thread computes "foo" but the helper callback has to do the "source.data = foo" part)

Thanks,

Bryan

···

On Jan 19, 2017, at 12:23 PM, Eugene Cheung <[email protected]> wrote:

Hi very sorry if I am missing something very obvious that was in the examples... but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.

On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:
Hi Eugene,

I'm still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

> On Jan 19, 2017, at 11:23 AM, Eugene Cheung <[email protected]> wrote:
>
> Hi Bryan,
>
> Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?
>
> On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:
> Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.
>
> --
> 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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/e777f913-933c-41e3-9f85-60b1cee81dde%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Perhaps these two sections:

  http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads

  http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-unlocked-callbacks

And this example:

  https://github.com/bokeh/bokeh/tree/master/examples/app/spectrogram

will be instructive.

Thanks,

Bryan

···

On Jan 19, 2017, at 12:53 PM, Eugene Cheung <[email protected]> wrote:

Right now i am still using the doc.add_next_tick_callback but just updating the entire source. Anybody know if this is the right way to do it?

YVal = 200
XVal = 0
source = ColumnDataSource(data=dict(x=, y=))
doc = curdoc()
def notify():
    time.sleep(5)
    doc.add_next_tick_callback(partial(update))
    
def update():
    print "i am here in update"
    global source
    s = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[20,20,20,20,20]))
    source.data.update(s.data)

p = figure(y_range=[0,100], plot_width=1000)
source = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[10,10,10,10,10]))
p.line(x='x', y='y', source=source)
doc.add_root(p)

thread = Thread(target = notify)
thread.start()

On Thursday, 19 January 2017 13:23:28 UTC-5, Eugene Cheung wrote:
Hi very sorry if I am missing something very obvious that was in the examples... but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.

On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:
Hi Eugene,

I'm still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

> On Jan 19, 2017, at 11:23 AM, Eugene Cheung <[email protected]> wrote:
>
> Hi Bryan,
>
> Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?
>
> On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:
> Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.
>
> --
> 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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/b39704e6-1044-414b-a3c2-6b453f4e9b54%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you so much Byran, I think I needed to create a new ColumnDataSource rather than updating the stream. Great stuff with Bokeh. Aesthetically its number one. Will love to contribute sometime.

···

On Thursday, 19 January 2017 14:02:52 UTC-5, Bryan Van de ven wrote:

Perhaps these two sections:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads](http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads)



    [http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-unlocked-callbacks](http://www.google.com/url?q=http%3A%2F%2Fbokeh.pydata.org%2Fen%2Flatest%2Fdocs%2Fuser_guide%2Fserver.html%23updating-from-unlocked-callbacks&sa=D&sntz=1&usg=AFQjCNFamyFnocv66kmbioLTkUJxjpVm_g)

And this example:

    [https://github.com/bokeh/bokeh/tree/master/examples/app/spectrogram](https://github.com/bokeh/bokeh/tree/master/examples/app/spectrogram)

will be instructive.

Thanks,

Bryan

On Jan 19, 2017, at 12:53 PM, Eugene Cheung [email protected] wrote:

Right now i am still using the doc.add_next_tick_callback but just updating the entire source. Anybody know if this is the right way to do it?

YVal = 200

XVal = 0

source = ColumnDataSource(data=dict(x=, y=))

doc = curdoc()
def notify():

time.sleep(5)
doc.add_next_tick_callback(partial(update))

def update():

print "i am here in update"
global source
s = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[20,20,20,20,20]))  
source.data.update(s.data)

p = figure(y_range=[0,100], plot_width=1000)

source = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[10,10,10,10,10]))
p.line(x=‘x’, y=‘y’, source=source)

doc.add_root§

thread = Thread(target = notify)

thread.start()

On Thursday, 19 January 2017 13:23:28 UTC-5, Eugene Cheung wrote:

Hi very sorry if I am missing something very obvious that was in the examples… but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.

On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:

Hi Eugene,

I’m still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?

Thanks,

Bryan

On Jan 19, 2017, at 11:23 AM, Eugene Cheung [email protected] wrote:

Hi Bryan,

Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?

On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:
Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.


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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/b39704e6-1044-414b-a3c2-6b453f4e9b54%40continuum.io.

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

Just to be clear and precise: I think the best demonstrated technique is to update the .data of an existing CDS, not create an entirely new CDS

Thanks,

Bryan

···

On Jan 19, 2017, at 1:47 PM, Eugene Cheung <[email protected]> wrote:

Thank you so much Byran, I think I needed to create a new ColumnDataSource rather than updating the stream. Great stuff with Bokeh. Aesthetically its number one. Will love to contribute sometime.

On Thursday, 19 January 2017 14:02:52 UTC-5, Bryan Van de ven wrote:
Perhaps these two sections:

        http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-threads

        http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#updating-from-unlocked-callbacks

And this example:

        https://github.com/bokeh/bokeh/tree/master/examples/app/spectrogram

will be instructive.

Thanks,

Bryan

> On Jan 19, 2017, at 12:53 PM, Eugene Cheung <[email protected]> wrote:
>
> Right now i am still using the doc.add_next_tick_callback but just updating the entire source. Anybody know if this is the right way to do it?
>
> YVal = 200
> XVal = 0
> source = ColumnDataSource(data=dict(x=, y=))
> doc = curdoc()
> def notify():
> time.sleep(5)
> doc.add_next_tick_callback(partial(update))
>
> def update():
> print "i am here in update"
> global source
> s = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[20,20,20,20,20]))
> source.data.update(s.data)
>
> p = figure(y_range=[0,100], plot_width=1000)
> source = ColumnDataSource(data=dict(x=[0,5,10,15,20], y=[10,10,10,10,10]))
> p.line(x='x', y='y', source=source)
> doc.add_root(p)
>
>
> thread = Thread(target = notify)
> thread.start()
>
> On Thursday, 19 January 2017 13:23:28 UTC-5, Eugene Cheung wrote:
> Hi very sorry if I am missing something very obvious that was in the examples... but how do you fire off an event (through the code) so that you can do your plot update. Right now I see examples using sliders/button clicks, but I want to do my update based on a certain event in my code. Thanks again.
>
> On Thursday, 19 January 2017 12:39:42 UTC-5, Bryan Van de ven wrote:
> Hi Eugene,
>
> I'm still missing some piece of context, as this still seems to describe all the existing examples to me, e.g. the app loads, then later a user scrubs a slider or clicks a button, or a timeout or periodic callback fires, and the plot is updated at that later time. Can you describe what you are hoping to accomplish with a bit more situational detail?
>
> Thanks,
>
> Bryan
>
>
> > On Jan 19, 2017, at 11:23 AM, Eugene Cheung <[email protected]> wrote:
> >
> > Hi Bryan,
> >
> > Thank you for helping me out once again. Yes, I do mean updating the plot all at once. But is it possible to refresh the same plot with new data (all at once) later on in the programs execution?
> >
> > On Thursday, 19 January 2017 11:33:59 UTC-5, Eugene Cheung wrote:
> > Hi, I was wondering if it is possible to update the ENTIRE plot at once (not point by point)? I am already using add_next_tick_callback for another graph but i.e. lets say I have points (x = [1,2,3] and y = [7,8,9]) and then when I am ready to update the plot to (x=[1,2,3,4,5,6] and y = [7,8,9,10,11,12] on the next draw. Speed is not too important (as long as its reasonable) but appending multiple points at the same time is key.
> >
> > --
> > 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/93f43d4c-33c0-4260-a510-5a805a62c1a9%40continuum.io.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>
>
> --
> 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/b39704e6-1044-414b-a3c2-6b453f4e9b54%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/6fd2185e-33db-44be-97c4-f0e53365aa78%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.