Plotting a cumulative value

It’s sometimes useful to plot a cumulative values s.t. when you zoom in the cumulation starts at 0 again. For instance plotting a cumulative timeseries then zooming in on a particular year would restart the cumulation from the beginning of the year. I’m guessing one could write a little javascript that does the cumulation and trigger it when the x range changes.

Does anyone have any advice for what the right way to do this is or have any examples of something similar.

–Tom

Hi Tom,

I don't know if you'd had any success. Depending on your use case, this
sounds like something that it would be easiest to express using the new
bokeh server.

You would just write some python code that updated your data source when
the range changes. Check out the examples directory for some ideas maybe?

Sincerely,

Sarah Bird

···

On 1/3/16 10:00 AM, Tom wrote:

It's sometimes useful to plot a cumulative values s.t. when you zoom in
the cumulation starts at 0 again. For instance plotting a cumulative
timeseries then zooming in on a particular year would restart the
cumulation from the beginning of the year. I'm guessing one could
write a little javascript that does the cumulation and trigger it when
the x range changes.

Does anyone have any advice for what the right way to do this is or have
any examples of something similar.

--Tom

--
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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Sarah,

Thanks for your answer. I was thinking that a client side solution might be more appropriate in this case because you want really good responsiveness. Does that make sense?

–Tom

···

On Thursday, January 14, 2016 at 1:47:34 AM UTC-5, Sarah Bird wrote:

Hi Tom,

I don’t know if you’d had any success. Depending on your use case, this

sounds like something that it would be easiest to express using the new

bokeh server.

You would just write some python code that updated your data source when

the range changes. Check out the examples directory for some ideas maybe?

Sincerely,

Sarah Bird

On 1/3/16 10:00 AM, Tom wrote:

It’s sometimes useful to plot a cumulative values s.t. when you zoom in

the cumulation starts at 0 again. For instance plotting a cumulative

timeseries then zooming in on a particular year would restart the

cumulation from the beginning of the year. I’m guessing one could

write a little javascript that does the cumulation and trigger it when

the x range changes.

Does anyone have any advice for what the right way to do this is or have

any examples of something similar.

–Tom


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]

mailto:[email protected].

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

mailto:[email protected].

To view this discussion on the web visit

https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io

<https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io?utm_medium=email&utm_source=footer>.

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

Tom,

Perhaps, although the responsiveness of, e.g.,

  http://demo.bokehplots.com/apps/selection_histogram

Seems quite good? It is doing a several histogram re-binnings on every selection, which I would imagine is more intensive than a simple cumulation.

That said, this could also be accomplished using a CustomJS callback on a plot's x_range, but it might require some cleverness. For instance, you would need to have all the data sent to the client and available. But that's not actually what you want to plot. We would like to add the notion "namespace variables" on a document, and that might be good for this, but that does not exist yet. So in the mean time, you could make a ColumnDataSource with all the data, attach that to an invisible glyph that doesn't actually get rendered, and then use that full data set to derive the summarized data for a glyph that does get rendered, in the callback.

Thanks,

Bryan

···

On Jan 14, 2016, at 9:42 AM, Tom <[email protected]> wrote:

Sarah,

Thanks for your answer. I was thinking that a client side solution might be more appropriate in this case because you want really good responsiveness. Does that make sense?

--Tom

On Thursday, January 14, 2016 at 1:47:34 AM UTC-5, Sarah Bird wrote:
Hi Tom,

I don't know if you'd had any success. Depending on your use case, this
sounds like something that it would be easiest to express using the new
bokeh server.

You would just write some python code that updated your data source when
the range changes. Check out the examples directory for some ideas maybe?

Sincerely,

Sarah Bird

On 1/3/16 10:00 AM, Tom wrote:
> It's sometimes useful to plot a cumulative values s.t. when you zoom in
> the cumulation starts at 0 again. For instance plotting a cumulative
> timeseries then zooming in on a particular year would restart the
> cumulation from the beginning of the year. I'm guessing one could
> write a little javascript that does the cumulation and trigger it when
> the x range changes.
>
> Does anyone have any advice for what the right way to do this is or have
> any examples of something similar.
>
> --Tom
>
> --
> 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 bokeh+un...@continuum.io
> <mailto:[email protected]>.
> To post to this group, send email to bo...@continuum.io
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io
> <https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
> 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/47a6e762-7b1f-4d72-91f7-b76dc4795ce5%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Indeed.

It would totally be possible, but given that someone can select an
arbitrary range, you will need to do the computation yourself and write
that in JS. Assuming the JS isn't a problem for you, it should still be
straight forward:
- get the range
- compute the new cumulative data
- set the data source with this new data

See CustomJS for RangeUpdate and the other CustomJS examples in the User
Guide for inspiration:

···

On 1/14/16 7:53 AM, Bryan Van de Ven wrote:

Tom,

Perhaps, although the responsiveness of, e.g.,

  http://demo.bokehplots.com/apps/selection_histogram

Seems quite good? It is doing a several histogram re-binnings on every selection, which I would imagine is more intensive than a simple cumulation.

That said, this could also be accomplished using a CustomJS callback on a plot's x_range, but it might require some cleverness. For instance, you would need to have all the data sent to the client and available. But that's not actually what you want to plot. We would like to add the notion "namespace variables" on a document, and that might be good for this, but that does not exist yet. So in the mean time, you could make a ColumnDataSource with all the data, attach that to an invisible glyph that doesn't actually get rendered, and then use that full data set to derive the summarized data for a glyph that does get rendered, in the callback.

Thanks,

Bryan

On Jan 14, 2016, at 9:42 AM, Tom <[email protected]> wrote:

Sarah,

Thanks for your answer. I was thinking that a client side solution might be more appropriate in this case because you want really good responsiveness. Does that make sense?

--Tom

On Thursday, January 14, 2016 at 1:47:34 AM UTC-5, Sarah Bird wrote:
Hi Tom,

I don't know if you'd had any success. Depending on your use case, this
sounds like something that it would be easiest to express using the new
bokeh server.

You would just write some python code that updated your data source when
the range changes. Check out the examples directory for some ideas maybe?

Sincerely,

Sarah Bird

On 1/3/16 10:00 AM, Tom wrote:

It's sometimes useful to plot a cumulative values s.t. when you zoom in
the cumulation starts at 0 again. For instance plotting a cumulative
timeseries then zooming in on a particular year would restart the
cumulation from the beginning of the year. I'm guessing one could
write a little javascript that does the cumulation and trigger it when
the x range changes.

Does anyone have any advice for what the right way to do this is or have
any examples of something similar.

--Tom

--
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 bokeh+un...@continuum.io
<mailto:[email protected]>.
To post to this group, send email to bo...@continuum.io
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/c9d320ae-ba06-46fe-8049-126f6862279e%40continuum.io?utm_medium=email&utm_source=footer&gt;\.
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/47a6e762-7b1f-4d72-91f7-b76dc4795ce5%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.