☰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

how to dynamically change axis range in BokehJS?

Community Support
jzhoup
jzhoup

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!

Jian

⌁   Link to post
Bryan
Bryan

Can you provide some code for what you are currently trying? It should be a matter of setting the start/end attributes of the relevant range objects on the Plot.

Bryan

···

On Feb 5, 2015, at 9:21 PM, jzhoup@gmail.com wrote:

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!
Jian

--
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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
jzhoup
jzhoup

what i am doing is basically hacking the html generated by bokeh output_file().

I managed to change the data dynamically by doing:

datasource = Bokeh.Collections(‘ColumnDataSource’).models[0]

#code to modify datasource

datasource.trigger(‘change’, datasource, {});

This worked.

I tried changing y_range by doing:

yrangesource = Bokeh.Collections(‘Range1d’).models[0]

yrangesource[“attributes”][“end”]=ymax

yrangesource[“attributes”][“start”]=ymin

I never managed to make this work correctly- it ends up just lifting x-axis to ymin positions.

something else I tried, with similar outcome:

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].pause()

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“end”]=ymax

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“start”]=ymin

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].unpause()

Jian

···

On Friday, February 6, 2015 at 9:06:32 PM UTC-5, Bryan Van de ven wrote:

Can you provide some code for what you are currently trying? It should be a matter of setting the start/end attributes of the relevant range objects on the Plot.

Bryan

On Feb 5, 2015, at 9:21 PM, jzh...@gmail.com wrote:

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!

Jian

–
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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

⌁   Link to post
euruswind
euruswind

I have found a solution to my problem…

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘start’]= ymin;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘end’]= ymax;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].update_range();

Jian

···

On Friday, February 6, 2015 at 11:41:30 PM UTC-5, jzh...@gmail.com wrote:

what i am doing is basically hacking the html generated by bokeh output_file().

I managed to change the data dynamically by doing:

datasource = Bokeh.Collections(‘ColumnDataSource’).models[0]

#code to modify datasource

datasource.trigger(‘change’, datasource, {});

This worked.

I tried changing y_range by doing:

yrangesource = Bokeh.Collections(‘Range1d’).models[0]

yrangesource[“attributes”][“end”]=ymax

yrangesource[“attributes”][“start”]=ymin

I never managed to make this work correctly- it ends up just lifting x-axis to ymin positions.

something else I tried, with similar outcome:

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].pause()

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“end”]=ymax

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“start”]=ymin

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].unpause()

Jian

On Friday, February 6, 2015 at 9:06:32 PM UTC-5, Bryan Van de ven wrote:

Can you provide some code for what you are currently trying? It should be a matter of setting the start/end attributes of the relevant range objects on the Plot.

Bryan

On Feb 5, 2015, at 9:21 PM, jzh...@gmail.com wrote:

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!

Jian

–
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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

⌁   Link to post
dekrion
dekrion

How do you obtain the “view” object?

Tony

···

On Sunday, February 8, 2015 at 9:26:16 PM UTC+1, Jian Zhou wrote:

I have found a solution to my problem…

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘start’]= ymin;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘end’]= ymax;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].update_range();

Jian

On Friday, February 6, 2015 at 11:41:30 PM UTC-5, jzh...@gmail.com wrote:

what i am doing is basically hacking the html generated by bokeh output_file().

I managed to change the data dynamically by doing:

datasource = Bokeh.Collections(‘ColumnDataSource’).models[0]

#code to modify datasource

datasource.trigger(‘change’, datasource, {});

This worked.

I tried changing y_range by doing:

yrangesource = Bokeh.Collections(‘Range1d’).models[0]

yrangesource[“attributes”][“end”]=ymax

yrangesource[“attributes”][“start”]=ymin

I never managed to make this work correctly- it ends up just lifting x-axis to ymin positions.

something else I tried, with similar outcome:

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].pause()

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“end”]=ymax

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“start”]=ymin

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].unpause()

Jian

On Friday, February 6, 2015 at 9:06:32 PM UTC-5, Bryan Van de ven wrote:

Can you provide some code for what you are currently trying? It should be a matter of setting the start/end attributes of the relevant range objects on the Plot.

Bryan

On Feb 5, 2015, at 9:21 PM, jzh...@gmail.com wrote:

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!

Jian

–
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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

⌁   Link to post
jzhoup
jzhoup

This is what I did ( I was using a very old version 0.7.1 though, not sure about new changes):
view = new model.default_view({model: model, el: ‘#98fbd618-e84d-415d-ba94-4ee29fb284f2’});
Bokeh.index[modelid] = view

Jian

···

On Friday, July 21, 2017 at 6:43:36 AM UTC-4, Tony Halik wrote:

How do you obtain the “view” object?

Tony

On Sunday, February 8, 2015 at 9:26:16 PM UTC+1, Jian Zhou wrote:

I have found a solution to my problem…

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘start’]= ymin;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘initial_range_info’][‘yrs’][‘default’][‘end’]= ymax;

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].update_range();

Jian

On Friday, February 6, 2015 at 11:41:30 PM UTC-5, jzh...@gmail.com wrote:

what i am doing is basically hacking the html generated by bokeh output_file().

I managed to change the data dynamically by doing:

datasource = Bokeh.Collections(‘ColumnDataSource’).models[0]

#code to modify datasource

datasource.trigger(‘change’, datasource, {});

This worked.

I tried changing y_range by doing:

yrangesource = Bokeh.Collections(‘Range1d’).models[0]

yrangesource[“attributes”][“end”]=ymax

yrangesource[“attributes”][“start”]=ymin

I never managed to make this work correctly- it ends up just lifting x-axis to ymin positions.

something else I tried, with similar outcome:

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].pause()

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“end”]=ymax

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”][‘y_range’][‘attributes’][“start”]=ymin

view[“views”][“4b4cf297-2307-402d-bcee-9db819fe8094”].unpause()

Jian

On Friday, February 6, 2015 at 9:06:32 PM UTC-5, Bryan Van de ven wrote:

Can you provide some code for what you are currently trying? It should be a matter of setting the start/end attributes of the relevant range objects on the Plot.

Bryan

On Feb 5, 2015, at 9:21 PM, jzh...@gmail.com wrote:

Hello,

I am developing a standalone webpage for visualization data only using bokehjs (0.7.1). I manage to update the plot with data, but I cannot figure out a way to update my axis ranges correctly ( e.g. after I adjust y range say from [0,1] to [-1,1], x axis appear in its original position i.e. 0, but I want it to be at -1 ). How could I update the ranges correctly?

Thanks!

Jian

–
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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%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