how to dynamically change axis range in BokehJS?

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

Hi Jian,

Could you post your code on jsfiddle to let other understand what is going on.
I made early tries with bokehJS at 0.6.0 release.
Not been able to use bokehJS 0.7.1 yet.
Try bokehJS with an ajax NCSS request
or others from http://jsfiddle.net/user/PBrockmann/fiddles/

Patrick

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

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, [email protected] 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 [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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

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, [email protected] 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, [email protected] 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 [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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

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, [email protected] 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, [email protected] 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 [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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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

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, [email protected] 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, [email protected] 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 [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/5d4f8c63-d1e8-407e-ada6-5131191efa2e%40continuum.io.

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