Remove renderers from plot (clear and redraw figure)

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

Hi,

···

There isn’t a way to clear a plot that i know of. I would probably have an empty column data source that i switch in and out. Or something like that, I’m not entirely understanding what you want to do.

Sarah Bird
[email protected]

On Apr 26, 2016, at 2:04 AM, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

Hi Sarah, thanks for your reply.

There isn’t a way to clear a plot that i know of. I would probably have an empty column data source that i switch in and out. Or something like that, I’m not entirely understanding what you want to do.

To keep it very simple, I want to dynamically change the lines that I plot in a figure, because they come from different datasets I select dynamically. This can be done easily with multi_line. But! I would also like to be able to obtain information on the original datasets through hover. multi_line, for now, has no hover support and I’m forced to use scatter or another renderer with hover support. These renderers do not support easily the fact of having multiple datasets!

Cheers,

Matteo

···

Sarah Bird
[email protected]

On Apr 26, 2016, at 2:04 AM, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

You could plot all datasets and have visibility controlled by a callback on_change on a RadioGroup?

radio = RadioGroup(labels = list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

where in the callback you set the line_render.glyph.line_alpha = 0

torsdag 28. april 2016 14.01.16 UTC+2 skrev [email protected] følgende:

···

Hi Sarah, thanks for your reply.

There isn’t a way to clear a plot that i know of. I would probably have an empty column data source that i switch in and out. Or something like that, I’m not entirely understanding what you want to do.

To keep it very simple, I want to dynamically change the lines that I plot in a figure, because they come from different datasets I select dynamically. This can be done easily with multi_line. But! I would also like to be able to obtain information on the original datasets through hover. multi_line, for now, has no hover support and I’m forced to use scatter or another renderer with hover support. These renderers do not support easily the fact of having multiple datasets!

Cheers,

Matteo

Sarah Bird
[email protected]

On Apr 26, 2016, at 2:04 AM, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

Hi Robert,

Yes, good point. The problem is that I need to visualize just 2-3 lines over probably some thousands. I fear this large number of renderers might make the server very slow.

Matteo

···

On Thursday, April 28, 2016 at 2:09:56 PM UTC+2, Robert wrote:

You could plot all datasets and have visibility controlled by a callback on_change on a RadioGroup?

radio = RadioGroup(labels = list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

where in the callback you set the line_render.glyph.line_alpha = 0

torsdag 28. april 2016 14.01.16 UTC+2 skrev [email protected] følgende:

Hi Sarah, thanks for your reply.

There isn’t a way to clear a plot that i know of. I would probably have an empty column data source that i switch in and out. Or something like that, I’m not entirely understanding what you want to do.

To keep it very simple, I want to dynamically change the lines that I plot in a figure, because they come from different datasets I select dynamically. This can be done easily with multi_line. But! I would also like to be able to obtain information on the original datasets through hover. multi_line, for now, has no hover support and I’m forced to use scatter or another renderer with hover support. These renderers do not support easily the fact of having multiple datasets!

Cheers,

Matteo

Sarah Bird
[email protected]

On Apr 26, 2016, at 2:04 AM, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

Hi Matteo!

That seems like a bit of a bother, yeah. What about generating the sources for the data and render them in a callback and do as Sarah proposed and set the previous source to an empty ColumnDatasource upon changing the third selection to avoid a cumbersome load?

Cheers,

Robert

···

2016-04-28 14:15 GMT+02:00 [email protected]:

Hi Robert,

Yes, good point. The problem is that I need to visualize just 2-3 lines over probably some thousands. I fear this large number of renderers might make the server very slow.

Matteo

On Thursday, April 28, 2016 at 2:09:56 PM UTC+2, Robert wrote:

You could plot all datasets and have visibility controlled by a callback on_change on a RadioGroup?

radio = RadioGroup(labels = list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

where in the callback you set the line_render.glyph.line_alpha = 0

torsdag 28. april 2016 14.01.16 UTC+2 skrev [email protected] følgende:

Hi Sarah, thanks for your reply.

There isn’t a way to clear a plot that i know of. I would probably have an empty column data source that i switch in and out. Or something like that, I’m not entirely understanding what you want to do.

To keep it very simple, I want to dynamically change the lines that I plot in a figure, because they come from different datasets I select dynamically. This can be done easily with multi_line. But! I would also like to be able to obtain information on the original datasets through hover. multi_line, for now, has no hover support and I’m forced to use scatter or another renderer with hover support. These renderers do not support easily the fact of having multiple datasets!

Cheers,

Matteo

Sarah Bird
[email protected]

On Apr 26, 2016, at 2:04 AM, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

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

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe.

To unsubscribe from this group and all its topics, 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/929a3739-0c91-4656-bdbf-4babf9fbd013%40continuum.io.

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

If you’re using bokeh server, this should be trivial, just set the data you want in
your callback. M any
of the server examples ()
do this

                            What

have you tried? What
isn’t this working for you? Can you share some code?

···

http://demo.bokehplots.com/.
On 4/28/16 5:47 AM, Robert Solli wrote:

Hi Matteo!

      That seems like a bit of a bother, yeah. What about

generating the sources for the data and render them in a
callback and do as Sarah proposed and set the previous source
to an empty ColumnDatasource upon changing the third selection
to avoid a cumbersome load?

Cheers,

Robert

2016-04-28 14:15 GMT+02:00 [email protected]:

Hi Robert,

          Yes, good point. The problem is that I need to visualize

just 2-3 lines over probably some thousands. I fear this
large number of renderers might make the server very slow.

          Matteo




              On Thursday, April 28, 2016 at 2:09:56 PM UTC+2,

Robert wrote:

                  You could plot all datasets and have

visibility controlled by a callback on_change on a
RadioGroup?

                    radio = RadioGroup(labels =

list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

                    where in the callback you set the

line_render.glyph.line_alpha = 0

                    torsdag 28. april 2016 14.01.16 UTC+2 skrev
                    følgende:

            You received this message because you are subscribed to

a topic in the Google Groups “Bokeh Discussion - Public”
group.

            To unsubscribe from this topic, visit [](https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe)                .

To unsubscribe from this group and all its topics, send
an email to .
To post to this group, send email to .

To view this discussion on the web visit .

  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/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com?utm_medium=email&utm_source=footer)      .

For more options, visit .


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

[email protected]

                        Hi Sarah, thanks for your

reply.

                              There isn't a way to clear a plot

that i know of. I would probably have
an empty column data source that i
switch in and out. Or something like
that, I’m not entirely understanding
what you want to do.

                          To keep it very simple, I want to

dynamically change the lines that I plot
in a figure, because they come from
different datasets I select dynamically.
This can be done easily with multi_line.
But! I would also like to be able to
obtain information on the original
datasets through hover. multi_line, for
now, has no hover support and I’m forced
to use scatter or another renderer with
hover support. These renderers do not
support easily the fact of having multiple
datasets!

                          Cheers,



                          Matteo
                              Sarah Bird

[email protected]

                              On Apr 26, 2016, at 2:04 AM,
                              wrote:

Hello everyone,

                                      I'm experimenting with Bokeh

server. I have a document with
three figures and I’m trying
to update two of them
depending on the selection I
perform on the third. The
number of lines to plot in the
two figures changes every
time.

                                      If I could use multi_line,

this would be trivial: I would
change the xs and ys in the
data_source of the multi_line.
Alas, I need to use multiple
scatter plots because
multi_line does not support
hover and I need it.

                                      So, what I would like to

accomplish is to clear the two
plots every time I select
something in the third, and
display the scatter plots
corresponding to the new
selection.

                                      There are a few possible

workarounds, of course
(appending scatter points to
have a single GlyphRenderer
with all scatter plots
together, for example, but
this would mean using very
clunky ways to send the right
hover message…). But if it
was possible to just clear and
update single figures,
everything would be cleaner. I
couldn’t find anything in the
docs, however.

                                      I hope the description is

clear enough. I can post some
minimal example if needed, of
course, I just need some time
to strip down the code.

                                      Thanks in advance for your

advice,

Matteo

                                      PS: I asked the same question

on SO ( ),
and I will try to update this
discussion if something
interesting is posted there,
and v.v.

                                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 .
To post to this group, send email to
.
To view this discussion on the web
visit .
For more options, visit .

[email protected]

http://stackoverflow.com/questions/36765561/remove-renderers-from-plot
[email protected]
[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io
https://groups.google.com/a/continuum.io/d/optout
https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe
[email protected]
[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/929a3739-0c91-4656-bdbf-4babf9fbd013%40continuum.io

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

https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com
https://groups.google.com/a/continuum.io/d/optout

I seem to have hit the exact same issue as Matteo and would appreciate digging in a little further.

I have a dataframe of multi-dimensional data, where the levels are something like source, destination, channel, stat. I use widgets that allow the user to select subsets of the values at each level, and the desire then is to just plot / display the selected stats. In total there are hundreds of columns (N source x N dest X N channels X N stats), and I generally only want to display a number of them simultaneously else the chart is too cluttered for practical use.

Currently I flatten the MultiIndex (i…e so each column has a string name like ‘node1, node2’, channel1, offload_queue_length’, and then create a ColumnDataSource from it. Then I iterate over the columns in the ColumnDataSource and add a line renderer to each plot, where x=‘index’, y=‘the flattened column name’, source=theColumnDataSource, and visible=False. Keeping a dictionary of the column names to renderer mapping allows me to easily adjust the visible attribute in the callbacks.

This works reasonably well, with the exception of performance and the Hovertool. Performance is obvious, creating all the renderers takes several seconds. For the HoverTool, responsiveness is sketchy even if I filter the .renderers property down to just the visible ones.

What I would love to do would be to only have renderers for the selected items, and then for example add circle glyphs for the hover tool to hopefully work better with. But I can’t see adding all those additional renderers to the plot and working with the visibility attributes - that would push performance too far down.

I wonder if I can dynamically change the y attribute of a renderer to point to different column_names in the dataset, and then just add renderers to the plot equal to the max number of columns selected - and then dynamically update the renderer -> column mappings. I suppose I’ll give this a shot, but man it would sure be nice to be able to add and remove renderers from the plot directly. Or maybe I should just be adding a new plot each time in the callback?

Thanks for any input!

-terry

···

On Tuesday, April 26, 2016 at 3:57:17 AM UTC-7, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

Just to clarify, when I say the Hovertool is sketchy, specifically I mean the labels do not consistently display. In the console the following exceptions are frequent:
Uncaught TypeError: Cannot read property ‘length’ of undefined

at LineView.exports.LineView.LineView._hit_point (line.js:63)

at LineView.exports.GlyphView.GlyphView.hit_test (glyph.js:245)

at GlyphRendererView.exports.GlyphRendererView.GlyphRendererView.hit_test (glyph_renderer.js:245)

at SelectionManager.exports.SelectionManager.SelectionManager.inspect (selection_manager.js:55)

at HoverToolView.exports.HoverToolView.HoverToolView._inspect (hover_tool.js:94)

at HoverToolView.exports.HoverToolView.HoverToolView._move (hover_tool.js:63)

at triggerEvents (events.js:245)

at triggerApi (events.js:227)

at eventsApi (events.js:44)

at UIEvents.exports.Events.trigger (events.js:216)

the function throws referencing this.sx in the for loop; there is no sx property on the object:

LineView.prototype._hit_point = function (geometry) {

/* Check if the point geometry hits this line glyph and return an object

that describes the hit result:

Args:

  • geometry (object): object with the following keys

  • vx (float): view x coordinate of the point

  • vy (float): view y coordinate of the point

  • type (str): type of geometry (in this case it’s a point)

Output:

Object with the following keys:

  • 0d (bool): whether the point hits the glyph or not

  • 1d (array(int)): array with the indices hit by the point

*/

var dist, i, j, p0, p1, point, ref, ref1, result, shortest, threshold;

result = hittest.create_hit_test_result();

point = {

x: this.renderer.plot_view.canvas.vx_to_sx(geometry.vx),

y: this.renderer.plot_view.canvas.vy_to_sy(geometry.vy)

};

shortest = 9999;

threshold = Math.max(2, this.visuals.line.line_width.value() / 2);

for (i = j = 0, ref = this.sx.length - 1; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {

ref1 = [

{

x: this.sx[i],

y: this.sy[i]

}, {

x: this.sx[i + 1],

y: this.sy[i + 1]

}

], p0 = ref1[0], p1 = ref1[1];

dist = hittest.dist_to_segment(point, p0, p1);

if (dist < threshold && dist < shortest) {

shortest = dist;

result[‘0d’].glyph = this.model;

result[‘0d’].get_view = (function () {

return this;

}).bind(this);

result[‘0d’].flag = true;

result[‘0d’].indices = [i];

}

}

return result;

};

···

On Tuesday, January 3, 2017 at 10:14:35 AM UTC-8, [email protected] wrote:

I seem to have hit the exact same issue as Matteo and would appreciate digging in a little further.

I have a dataframe of multi-dimensional data, where the levels are something like source, destination, channel, stat. I use widgets that allow the user to select subsets of the values at each level, and the desire then is to just plot / display the selected stats. In total there are hundreds of columns (N source x N dest X N channels X N stats), and I generally only want to display a number of them simultaneously else the chart is too cluttered for practical use.

Currently I flatten the MultiIndex (i…e so each column has a string name like ‘node1, node2’, channel1, offload_queue_length’, and then create a ColumnDataSource from it. Then I iterate over the columns in the ColumnDataSource and add a line renderer to each plot, where x=‘index’, y=‘the flattened column name’, source=theColumnDataSource, and visible=False. Keeping a dictionary of the column names to renderer mapping allows me to easily adjust the visible attribute in the callbacks.

This works reasonably well, with the exception of performance and the Hovertool. Performance is obvious, creating all the renderers takes several seconds. For the HoverTool, responsiveness is sketchy even if I filter the .renderers property down to just the visible ones.

What I would love to do would be to only have renderers for the selected items, and then for example add circle glyphs for the hover tool to hopefully work better with. But I can’t see adding all those additional renderers to the plot and working with the visibility attributes - that would push performance too far down.

I wonder if I can dynamically change the y attribute of a renderer to point to different column_names in the dataset, and then just add renderers to the plot equal to the max number of columns selected - and then dynamically update the renderer -> column mappings. I suppose I’ll give this a shot, but man it would sure be nice to be able to add and remove renderers from the plot directly. Or maybe I should just be adding a new plot each time in the callback?

Thanks for any input!

-terry

On Tuesday, April 26, 2016 at 3:57:17 AM UTC-7, [email protected] wrote:

Hello everyone,

I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.

If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.

So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.

There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.

I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.

Thanks in advance for your advice,

Matteo

PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.

Hi,

it would seem I’ve run into this issue as well.

My use case is quite simple: I’d like to achieve the effect of the selection based histogram (i.e. https://demo.bokehplots.com/apps/selection_histogram) but with a pie chart instead.

Calling chart.Donut is not an option because to update it, I need to toss the chart and redraw it.

So instead, I’m using a figure object and drawing a series of wedges on it.

But even though I have the list of wedges, I can’t update their start/stop angles, nor can I remove them, nor can I clear the figure.

What alternatives do I have?

Thanks,
Memet

···

On Friday, April 29, 2016 at 6:05:43 AM UTC+10, Sarah Bird wrote:

If you’re using bokeh server, this should be trivial, just set the data you want in
your callback. M any
of the server examples (http://demo.bokehplots.com/ )
do this.

                            What

have you tried? What
isn’t this working for you? Can you share some code?

On 4/28/16 5:47 AM, Robert Solli wrote:

Hi Matteo!

      That seems like a bit of a bother, yeah. What about

generating the sources for the data and render them in a
callback and do as Sarah proposed and set the previous source
to an empty ColumnDatasource upon changing the third selection
to avoid a cumbersome load?

Cheers,

Robert

2016-04-28 14:15 GMT+02:00 [email protected]:

Hi Robert,

          Yes, good point. The problem is that I need to visualize

just 2-3 lines over probably some thousands. I fear this
large number of renderers might make the server very slow.

          Matteo




              On Thursday, April 28, 2016 at 2:09:56 PM UTC+2, > > > Robert wrote:
                  You could plot all datasets and have

visibility controlled by a callback on_change on a
RadioGroup?

                    radio = RadioGroup(labels =

list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

                    where in the callback you set the

line_render.glyph.line_alpha = 0

                    torsdag 28. april 2016 14.01.16 UTC+2 skrev [email protected]
                    følgende:
                        Hi Sarah, thanks for your

reply.

                              There isn't a way to clear a plot

that i know of. I would probably have
an empty column data source that i
switch in and out. Or something like
that, I’m not entirely understanding
what you want to do.

                          To keep it very simple, I want to

dynamically change the lines that I plot
in a figure, because they come from
different datasets I select dynamically.
This can be done easily with multi_line.
But! I would also like to be able to
obtain information on the original
datasets through hover. multi_line, for
now, has no hover support and I’m forced
to use scatter or another renderer with
hover support. These renderers do not
support easily the fact of having multiple
datasets!

                          Cheers,



                          Matteo
                              Sarah Bird

[email protected]

                              On Apr 26, 2016, at 2:04 AM, [email protected] > > > > > >                                   wrote:

Hello everyone,

                                      I'm experimenting with Bokeh

server. I have a document with
three figures and I’m trying
to update two of them
depending on the selection I
perform on the third. The
number of lines to plot in the
two figures changes every
time.

                                      If I could use multi_line,

this would be trivial: I would
change the xs and ys in the
data_source of the multi_line.
Alas, I need to use multiple
scatter plots because
multi_line does not support
hover and I need it.

                                      So, what I would like to

accomplish is to clear the two
plots every time I select
something in the third, and
display the scatter plots
corresponding to the new
selection.

                                      There are a few possible

workarounds, of course
(appending scatter points to
have a single GlyphRenderer
with all scatter plots
together, for example, but
this would mean using very
clunky ways to send the right
hover message…). But if it
was possible to just clear and
update single figures,
everything would be cleaner. I
couldn’t find anything in the
docs, however.

                                      I hope the description is

clear enough. I can post some
minimal example if needed, of
course, I just need some time
to strip down the code.

                                      Thanks in advance for your

advice,

Matteo

                                      PS: I asked the same question

on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot ),
and I will try to update this
discussion if something
interesting is posted there,
and v.v.

                                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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

            You received this message because you are subscribed to

a topic in the Google Groups “Bokeh Discussion - Public”
group.

            To unsubscribe from this topic, visit [](https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe)[https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe](https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe).

            To unsubscribe from this group and all its topics, 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/929a3739-0c91-4656-bdbf-4babf9fbd013%40continuum.io.

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](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/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px">
    ](http://continuum.io)

Hi,

Updating the data for the wedges including their start/end angles should be no problem. Can you provide code that shows exactly what you’re trying?

Bryan

···

On Jun 27, 2017, at 19:28, [email protected] wrote:

Hi,

it would seem I’ve run into this issue as well.

My use case is quite simple: I’d like to achieve the effect of the selection based histogram (i.e. https://demo.bokehplots.com/apps/selection_histogram) but with a pie chart instead.

Calling chart.Donut is not an option because to update it, I need to toss the chart and redraw it.

So instead, I’m using a figure object and drawing a series of wedges on it.

But even though I have the list of wedges, I can’t update their start/stop angles, nor can I remove them, nor can I clear the figure.

What alternatives do I have?

Thanks,
Memet

On Friday, April 29, 2016 at 6:05:43 AM UTC+10, Sarah Bird wrote:

If you’re using bokeh server, this should be trivial, just set the data you want in
your callback. M any
of the server examples (http://demo.bokehplots.com/ )
do this.

                            What

have you tried? What
isn’t this working for you? Can you share some code?

On 4/28/16 5:47 AM, Robert Solli wrote:

Hi Matteo!

      That seems like a bit of a bother, yeah. What about

generating the sources for the data and render them in a
callback and do as Sarah proposed and set the previous source
to an empty ColumnDatasource upon changing the third selection
to avoid a cumbersome load?

Cheers,

Robert

2016-04-28 14:15 GMT+02:00 [email protected]:

Hi Robert,

          Yes, good point. The problem is that I need to visualize

just 2-3 lines over probably some thousands. I fear this
large number of renderers might make the server very slow.

          Matteo




              On Thursday, April 28, 2016 at 2:09:56 PM UTC+2, > > > > Robert wrote:
                  You could plot all datasets and have

visibility controlled by a callback on_change on a
RadioGroup?

                    radio = RadioGroup(labels =

list_of_dataset_names, active = 0)

radio.on_change(“active”, callback())

                    where in the callback you set the

line_render.glyph.line_alpha = 0

                    torsdag 28. april 2016 14.01.16 UTC+2 skrev [email protected]
                    følgende:
                        Hi Sarah, thanks for your

reply.

                              There isn't a way to clear a plot

that i know of. I would probably have
an empty column data source that i
switch in and out. Or something like
that, I’m not entirely understanding
what you want to do.

                          To keep it very simple, I want to

dynamically change the lines that I plot
in a figure, because they come from
different datasets I select dynamically.
This can be done easily with multi_line.
But! I would also like to be able to
obtain information on the original
datasets through hover. multi_line, for
now, has no hover support and I’m forced
to use scatter or another renderer with
hover support. These renderers do not
support easily the fact of having multiple
datasets!

                          Cheers,



                          Matteo
                              Sarah Bird

[email protected]

                              On Apr 26, 2016, at 2:04 AM, [email protected] > > > > > > >                                   wrote:

Hello everyone,

                                      I'm experimenting with Bokeh

server. I have a document with
three figures and I’m trying
to update two of them
depending on the selection I
perform on the third. The
number of lines to plot in the
two figures changes every
time.

                                      If I could use multi_line,

this would be trivial: I would
change the xs and ys in the
data_source of the multi_line.
Alas, I need to use multiple
scatter plots because
multi_line does not support
hover and I need it.

                                      So, what I would like to

accomplish is to clear the two
plots every time I select
something in the third, and
display the scatter plots
corresponding to the new
selection.

                                      There are a few possible

workarounds, of course
(appending scatter points to
have a single GlyphRenderer
with all scatter plots
together, for example, but
this would mean using very
clunky ways to send the right
hover message…). But if it
was possible to just clear and
update single figures,
everything would be cleaner. I
couldn’t find anything in the
docs, however.

                                      I hope the description is

clear enough. I can post some
minimal example if needed, of
course, I just need some time
to strip down the code.

                                      Thanks in advance for your

advice,

Matteo

                                      PS: I asked the same question

on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot ),
and I will try to update this
discussion if something
interesting is posted there,
and v.v.

                                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/f1ba6d9e-ffcb-4046-b173-c3d2ee0b825e%40continuum.io.

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

            You received this message because you are subscribed to

a topic in the Google Groups “Bokeh Discussion - Public”
group.

            To unsubscribe from this topic, visit [](https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe)[https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe](https://groups.google.com/a/continuum.io/d/topic/bokeh/1ovbaXFOtSw/unsubscribe).

            To unsubscribe from this group and all its topics, 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/929a3739-0c91-4656-bdbf-4babf9fbd013%40continuum.io.

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](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/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com](https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BAkX391ESiHhH0QpwxMTkmPC2sr1t%3DOti8DyNmV17y%2Bg7SGxg%40mail.gmail.com).

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


Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" width="150px" height="30px">
    ](http://continuum.io)

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/65cf8682-e9ab-402c-91c9-b64b559a9e6a%40continuum.io.

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