☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

can I change figure's para in update?

Community Support
Qiwei_Peng
Qiwei_Peng

I created interactive bar by rect, due to my different x_axis, I wish to change my figure’s x_range, so to change the bar’s x_axis name.
Here are some of my codes:

xis_map = {

“Current Location”:location,

#‘Current Company’:‘company’,

“Current Industry”:industry,

“Current Company”:company

}

y_map ={

“Current Location”:local_counts1,

“Current Industry”:industry_counts1

}

height_map={

“Current Location”:y_local_height,

“Current Industry”:y_indus_height,

“Current Company”:y_company_height

}

cities=TextInput(title=‘location name’)

x_axis=Select(title=‘X axis’,options=sorted(axis_map.keys()),value=‘Current Industry’)

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

plot = figure(plot_height=600, plot_width=800, title="", toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])

plot.rect(x=‘x’,y=‘y’,width=.8,height=‘height’,source=source)

#Callback_Age = CustomJS(args={’’})

def update():

plot.xaxis.axis_label=x_axis.value

plot.yaxis.axis_label=‘numbers’

source.data=dict(

x=axis_map[x_axis.value],

y=height_map[x_axis.value],

height=height_map[x_axis.value]*2.0,

x_range_name=axis_map[x_axis.value]

)

#bokeh.plotting.curplot().x_range=axis_map[x_axis.value]

def input_change(attrname,old,new):

update()

controls=[cities,x_axis]

for control in controls:

control.on_change('value',input_change)

inputs=HBox(VBoxForm(*controls))

input_change(None,None,None)

curdoc().add_root(HBox(inputs,plot))

in the line plot=figure,the value of x_range will be the value of my x_axis, I want to change it every time I update my data.

is there any solution?

⌁   Link to post
Bryan
Bryan

Hi,

There are two different kinds of callbacks, and it is important to keep the distinction in mind:

* CustomJS -- these run *javascip code* and only execute *in the browser* No "real" python code is possible here

* Bokeh server -- these are python funcs, passed to .on_change and execute actual python code *on the server*

It's hard to give any concrete advice without knowing more about what you are actually trying to accomplish.

There are numerous examples you can study, however. There is information and examples of CustomJS callbacks here:

  http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#javascript-callbacks

And there are various example of using the server and server callbacks here:

  https://github.com/bokeh/bokeh/tree/0.11.1/examples/app

Note: I've referenced the GitHub repo at the latest stable release tag, 0.11.1

Thanks,

Bryan

···

On Jun 4, 2016, at 11:10 AM, Qiwei Peng <pengqiwei.pqw@gmail.com> wrote:

I created interactive bar by rect, due to my different x_axis, I wish to change my figure's x_range, so to change the bar's x_axis name.
Here are some of my codes:

xis_map = {
    "Current Location":location,
    #'Current Company':'company',
    "Current Industry":industry,
    "Current Company":company
}

y_map ={
    "Current Location":local_counts1,
    "Current Industry":industry_counts1
}
height_map={
    "Current Location":y_local_height,
    "Current Industry":y_indus_height,
    "Current Company":y_company_height
}

cities=TextInput(title='location name')
x_axis=Select(title='X axis',options=sorted(axis_map.keys()),value='Current Industry')

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

plot = figure(plot_height=600, plot_width=800, title="", toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])
plot.rect(x='x',y='y',width=.8,height='height',source=source)

#Callback_Age = CustomJS(args={''})

def update():

    plot.xaxis.axis_label=x_axis.value
    plot.yaxis.axis_label='numbers'

    source.data=dict(
        x=axis_map[x_axis.value],
        y=height_map[x_axis.value],
        height=height_map[x_axis.value]*2.0,
        x_range_name=axis_map[x_axis.value]

        )
    bokeh.plotting.curplot().x_range=axis_map[x_axis.value]
  
def input_change(attrname,old,new):
    update()

controls=[cities,x_axis]
for control in controls:
  control.on_change('value',input_change)

inputs=HBox(VBoxForm(*controls))
input_change(None,None,None)
curdoc().add_root(HBox(inputs,plot))

in the line plot=figure,the value of x_range will be the value of my x_axis, I want to change it every time I update my data.
is there any solution?

--
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+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3946f375-c08d-4886-898b-f1955a27061b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Qiwei_Peng
Qiwei_Peng

I will try CustomJS
and if you don’t mind:

here:

plot = figure(plot_height=600, plot_width=800, title=“”, toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])

plot.rect(x=‘x’,y=‘y’,width=.8,height=‘height’,source=source)

I hope I could change the figure’s x_range data in every update, is it possible in CustomJS?

在 2016年6月5日星期日 UTC+8上午4:21:53,Bryan Van de ven写道:

···

Hi,

There are two different kinds of callbacks, and it is important to keep the distinction in mind:

  • CustomJS – these run javascip code and only execute in the browser No “real” python code is possible here

  • Bokeh server – these are python funcs, passed to .on_change and execute actual python code on the server

It’s hard to give any concrete advice without knowing more about what you are actually trying to accomplish.

There are numerous examples you can study, however. There is information and examples of CustomJS callbacks here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#javascript-callbacks](http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#javascript-callbacks)

And there are various example of using the server and server callbacks here:

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

Note: I’ve referenced the GitHub repo at the latest stable release tag, 0.11.1

Thanks,

Bryan

On Jun 4, 2016, at 11:10 AM, Qiwei Peng pengqi...@gmail.com wrote:

I created interactive bar by rect, due to my different x_axis, I wish to change my figure’s x_range, so to change the bar’s x_axis name.

Here are some of my codes:

xis_map = {

"Current Location":location,
#'Current Company':'company',
"Current Industry":industry,
"Current Company":company

}

y_map ={

"Current Location":local_counts1,
"Current Industry":industry_counts1

}

height_map={

"Current Location":y_local_height,
"Current Industry":y_indus_height,
"Current Company":y_company_height

}

cities=TextInput(title=‘location name’)

x_axis=Select(title=‘X axis’,options=sorted(axis_map.keys()),value=‘Current Industry’)

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

plot = figure(plot_height=600, plot_width=800, title=“”, toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])

plot.rect(x=‘x’,y=‘y’,width=.8,height=‘height’,source=source)

#Callback_Age = CustomJS(args={‘’})

def update():

plot.xaxis.axis_label=x_axis.value
plot.yaxis.axis_label='numbers'
source.data=dict(
    x=axis_map[x_axis.value],
    y=height_map[x_axis.value],
    height=height_map[x_axis.value]*2.0,
    x_range_name=axis_map[x_axis.value]
    )
#bokeh.plotting.curplot().x_range=axis_map[x_axis.value]

def input_change(attrname,old,new):

update()

controls=[cities,x_axis]

for control in controls:

    control.on_change('value',input_change)

inputs=HBox(VBoxForm(*controls))

input_change(None,None,None)

curdoc().add_root(HBox(inputs,plot))

in the line plot=figure,the value of x_range will be the value of my x_axis, I want to change it every time I update my data.

is there any solution?

–
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.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3946f375-c08d-4886-898b-f1955a27061b%40continuum.io.

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

⌁   Link to post
Qiwei_Peng
Qiwei_Peng

is there any where I can check figure’s **parameters, the x_range and y_range, in the official document, I can’t see it ,**only rect and others can be seen.

在 2016年6月5日星期日 UTC+8上午4:21:53,Bryan Van de ven写道:

···

Hi,

There are two different kinds of callbacks, and it is important to keep the distinction in mind:

  • CustomJS – these run javascip code and only execute in the browser No “real” python code is possible here

  • Bokeh server – these are python funcs, passed to .on_change and execute actual python code on the server

It’s hard to give any concrete advice without knowing more about what you are actually trying to accomplish.

There are numerous examples you can study, however. There is information and examples of CustomJS callbacks here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#javascript-callbacks](http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#javascript-callbacks)

And there are various example of using the server and server callbacks here:

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

Note: I’ve referenced the GitHub repo at the latest stable release tag, 0.11.1

Thanks,

Bryan

On Jun 4, 2016, at 11:10 AM, Qiwei Peng pengqi...@gmail.com wrote:

I created interactive bar by rect, due to my different x_axis, I wish to change my figure’s x_range, so to change the bar’s x_axis name.

Here are some of my codes:

xis_map = {

"Current Location":location,
#'Current Company':'company',
"Current Industry":industry,
"Current Company":company

}

y_map ={

"Current Location":local_counts1,
"Current Industry":industry_counts1

}

height_map={

"Current Location":y_local_height,
"Current Industry":y_indus_height,
"Current Company":y_company_height

}

cities=TextInput(title=‘location name’)

x_axis=Select(title=‘X axis’,options=sorted(axis_map.keys()),value=‘Current Industry’)

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

plot = figure(plot_height=600, plot_width=800, title=“”, toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])

plot.rect(x=‘x’,y=‘y’,width=.8,height=‘height’,source=source)

#Callback_Age = CustomJS(args={‘’})

def update():

plot.xaxis.axis_label=x_axis.value
plot.yaxis.axis_label='numbers'
source.data=dict(
    x=axis_map[x_axis.value],
    y=height_map[x_axis.value],
    height=height_map[x_axis.value]*2.0,
    x_range_name=axis_map[x_axis.value]
    )
#bokeh.plotting.curplot().x_range=axis_map[x_axis.value]

def input_change(attrname,old,new):

update()

controls=[cities,x_axis]

for control in controls:

    control.on_change('value',input_change)

inputs=HBox(VBoxForm(*controls))

input_change(None,None,None)

curdoc().add_root(HBox(inputs,plot))

in the line plot=figure,the value of x_range will be the value of my x_axis, I want to change it every time I update my data.

is there any solution?

–
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.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3946f375-c08d-4886-898b-f1955a27061b%40continuum.io.

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

⌁   Link to post

End of archived discussion · Replies are disabled