setting circle glyph size with slider

I am trying to use the slider widget to get user-provided value to set the size of the circle. I am using bokeh server to do this. But i am running into issues with setting up the columndatasource.

Another related question is there a way to create circle glyphs of different size using the same statement?

This is the code I have thus far for working with the slider:

···

from bokeh.plotting import Figure

from bokeh.models import HBox, ColumnDataSource

from bokeh.models.widgets import Slider

from bokeh.io import curdoc

cir_x=[2]

cir_y=[10]

cir_size=5

cir_source = ColumnDataSource(data=dict(

x=cir_x,

y=cir_y,

sz=cir_size

))

plot = Figure(plot_width=400, plot_height=400, title=‘Changing the size of circle’,

x_range=[0,20], y_range=[0,20])

plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)

sz_slide = Slider(start=0, end=20, step=1, value=5, title=“Circle Size”)

def update_radius(attrname, old, new):

a = sz_slide.value

x=[2]

y=[10]

cir_source.data = dict(x=x,y=y,sz=a)

for w in [sz_slide]:

w.on_change(‘value’, update_radius)

h_layout = HBox(children=[plot,sz_slide])

curdoc().add_root(h_layout)

Have you tried

a = [sz_slide.value]

    as opposed to

    a = sz_slide.value  
···

On 4/28/16 6:57 AM,
wrote:

[email protected]

    I am trying to use the slider widget to get

user-provided value to set the size of the circle. I am using
bokeh server to do this. But i am running into issues with
setting up the columndatasource.

      Another related question is there a way to create circle

glyphs of different size using the same statement?

        This is the code I have thus far for working with the

slider:


from bokeh.plotting import Figure

from bokeh.models import HBox, ColumnDataSource

from bokeh.models.widgets import Slider

from bokeh.io import curdoc

cir_x=[2]

cir_y=[10]

cir_size=5

cir_source = ColumnDataSource(data=dict(

x=cir_x,

y=cir_y,

sz=cir_size

))

            plot = Figure(plot_width=400, plot_height=400,

title=‘Changing the size of circle’,

x_range=[0,20], y_range=[0,20])

plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)

            sz_slide = Slider(start=0, end=20, step=1, value=5,

title=“Circle Size”)

def update_radius(attrname, old, new):

a = sz_slide.value

x=[2]

y=[10]

cir_source.data = dict(x=x,y=y,sz=a)

for w in [sz_slide]:

w.on_change(‘value’, update_radius)

h_layout = HBox(children=[plot,sz_slide])

curdoc().add_root(h_layout)

  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/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io?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)

https://groups.google.com/a/continuum.io/d/msgid/bokeh/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io
https://groups.google.com/a/continuum.io/d/optout

Worked like a charm! I had some variation of it but in vain!

···

On Thursday, April 28, 2016 at 3:55:20 PM UTC-4, Sarah Bird wrote:

Have you tried

a = [sz_slide.value]



    as opposed to



    a = sz_slide.value  





       


  On 4/28/16 6:57 AM, > [email protected] wrote:
    I am trying to use the slider widget to get

user-provided value to set the size of the circle. I am using
bokeh server to do this. But i am running into issues with
setting up the columndatasource.

      Another related question is there a way to create circle

glyphs of different size using the same statement?

        This is the code I have thus far for working with the

slider:


from bokeh.plotting import Figure

from bokeh.models import HBox, ColumnDataSource

from bokeh.models.widgets import Slider

from bokeh.io import curdoc

cir_x=[2]

cir_y=[10]

cir_size=5

cir_source = ColumnDataSource(data=dict(

x=cir_x,

y=cir_y,

sz=cir_size

))

            plot = Figure(plot_width=400, plot_height=400,

title=‘Changing the size of circle’,

x_range=[0,20], y_range=[0,20])

plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)

            sz_slide = Slider(start=0, end=20, step=1, value=5,

title=“Circle Size”)

def update_radius(attrname, old, new):

a = sz_slide.value

x=[2]

y=[10]

cir_source.data = dict(x=x,y=y,sz=a)

for w in [sz_slide]:

w.on_change(‘value’, update_radius)

h_layout = HBox(children=[plot,sz_slide])

curdoc().add_root(h_layout)

  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/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io).

  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" height="30px" width="150px">
    ](http://continuum.io)

When I run the code it gives me the following error:

ValueError: expected an element of Dict(String, Seq(Any)), got {'y': [10], 'sz': 5}
And I can fix the error by changing
cir_size=5
to
cir_size=[5]

But the slider does not change the radius of the circle. Could you please help me? Thanks
···

On Thursday, April 28, 2016 at 1:01:25 PM UTC-7, Jn Rdh wrote:

Worked like a charm! I had some variation of it but in vain!

On Thursday, April 28, 2016 at 3:55:20 PM UTC-4, Sarah Bird wrote:

Have you tried

a = [sz_slide.value]



    as opposed to



    a = sz_slide.value  





       


  On 4/28/16 6:57 AM, > > [email protected] wrote:
    I am trying to use the slider widget to get

user-provided value to set the size of the circle. I am using
bokeh server to do this. But i am running into issues with
setting up the columndatasource.

      Another related question is there a way to create circle

glyphs of different size using the same statement?

        This is the code I have thus far for working with the

slider:


from bokeh.plotting import Figure

from bokeh.models import HBox, ColumnDataSource

from bokeh.models.widgets import Slider

from bokeh.io import curdoc

cir_x=[2]

cir_y=[10]

cir_size=5

cir_source = ColumnDataSource(data=dict(

x=cir_x,

y=cir_y,

sz=cir_size

))

            plot = Figure(plot_width=400, plot_height=400,

title=‘Changing the size of circle’,

x_range=[0,20], y_range=[0,20])

plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)

            sz_slide = Slider(start=0, end=20, step=1, value=5,

title=“Circle Size”)

def update_radius(attrname, old, new):

a = sz_slide.value

x=[2]

y=[10]

cir_source.data = dict(x=x,y=y,sz=a)

for w in [sz_slide]:

w.on_change(‘value’, update_radius)

h_layout = HBox(children=[plot,sz_slide])

curdoc().add_root(h_layout)

  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/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io).

  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" height="30px" width="150px">
    ](http://continuum.io)

Hi,

Please see this other recent post about the need to call session.loop_until_closed (or better: writing a native server app):

  https://groups.google.com/a/continuum.io/d/msg/bokeh/CtrZGIvdCjI/HYbhGMGjCQAJ

Thanks,

Bryan

···

On Nov 3, 2016, at 3:40 PM, [email protected] wrote:

When I run the code it gives me the following error:
ValueError: expected an element of Dict(String, Seq(Any)), got {'y': [10], 'sz': 5}
And I can fix the error by changing
cir_size=5
to
cir_size=[5]
But the slider does not change the radius of the circle. Could you please help me? Thanks

On Thursday, April 28, 2016 at 1:01:25 PM UTC-7, Jn Rdh wrote:
Worked like a charm! I had some variation of it but in vain!

On Thursday, April 28, 2016 at 3:55:20 PM UTC-4, Sarah Bird wrote:
Have you tried

a = [sz_slide.value]

as opposed to

a = sz_slide.value

On 4/28/16 6:57 AM, [email protected] wrote:

I am trying to use the slider widget to get user-provided value to set the size of the circle. I am using bokeh server to do this. But i am running into issues with setting up the columndatasource.

Another related question is there a way to create circle glyphs of different size using the same statement?

This is the code I have thus far for working with the slider:
----------------------------------------------------------------

from bokeh.plotting import Figure
from bokeh.models import HBox, ColumnDataSource
from bokeh.models.widgets import Slider
from bokeh.io import curdoc

cir_x=[2]
cir_y=[10]
cir_size=5

cir_source = ColumnDataSource(data=dict(
                                x=cir_x,
                                y=cir_y,
                                sz=cir_size
                                ))
                                
plot = Figure(plot_width=400, plot_height=400, title='Changing the size of circle',
              x_range=[0,20], y_range=[0,20])
              
plot.circle('x', 'y', size='sz', source=cir_source)

sz_slide = Slider(start=0, end=20, step=1, value=5, title="Circle Size")

def update_radius(attrname, old, new):
    a = sz_slide.value
  
    x=[2]
    y=[10]
    cir_source.data = dict(x=x,y=y,sz=a)
   
for w in [sz_slide]:
    w.on_change('value', update_radius)

h_layout = HBox(children=[plot,sz_slide])
curdoc().add_root(h_layout)

--
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/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
Sarah Bird
Developer, Bokeh

--
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/e0b3ed18-4b96-400f-ac8e-c395788a521a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan.

···

On Thursday, November 3, 2016 at 4:06:03 PM UTC-7, Bryan Van de ven wrote:

Hi,

Please see this other recent post about the need to call session.loop_until_closed (or better: writing a native server app):

    [https://groups.google.com/a/continuum.io/d/msg/bokeh/CtrZGIvdCjI/HYbhGMGjCQAJ](https://groups.google.com/a/continuum.io/d/msg/bokeh/CtrZGIvdCjI/HYbhGMGjCQAJ)

Thanks,

Bryan

On Nov 3, 2016, at 3:40 PM, [email protected] wrote:

When I run the code it gives me the following error:

ValueError: expected an element of Dict(String, Seq(Any)), got {‘y’: [10], ‘sz’: 5}

And I can fix the error by changing
cir_size=5

to
cir_size=[5]

But the slider does not change the radius of the circle. Could you please help me? Thanks

On Thursday, April 28, 2016 at 1:01:25 PM UTC-7, Jn Rdh wrote:

Worked like a charm! I had some variation of it but in vain!

On Thursday, April 28, 2016 at 3:55:20 PM UTC-4, Sarah Bird wrote:

Have you tried

a = [sz_slide.value]

as opposed to

a = sz_slide.value

On 4/28/16 6:57 AM, [email protected] wrote:

I am trying to use the slider widget to get user-provided value to set the size of the circle. I am using bokeh server to do this. But i am running into issues with setting up the columndatasource.

Another related question is there a way to create circle glyphs of different size using the same statement?

This is the code I have thus far for working with the slider:


from bokeh.plotting import Figure

from bokeh.models import HBox, ColumnDataSource

from bokeh.models.widgets import Slider

from bokeh.io import curdoc

cir_x=[2]

cir_y=[10]

cir_size=5

cir_source = ColumnDataSource(data=dict(

                            x=cir_x,
                            y=cir_y,
                            sz=cir_size
                            ))

plot = Figure(plot_width=400, plot_height=400, title=‘Changing the size of circle’,
x_range=[0,20], y_range=[0,20])

plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)

sz_slide = Slider(start=0, end=20, step=1, value=5, title=“Circle Size”)

def update_radius(attrname, old, new):

a = sz_slide.value  

x=[2]    
y=[10]
cir_source.data = dict(x=x,y=y,sz=a)

for w in [sz_slide]:

w.on_change('value', update_radius)

h_layout = HBox(children=[plot,sz_slide])

curdoc().add_root(h_layout)


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/90d9dcb7-8827-47a8-b701-44a4c3c4573f%40continuum.io.

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


Sarah Bird

Developer, Bokeh


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/e0b3ed18-4b96-400f-ac8e-c395788a521a%40continuum.io.

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