How to update ResetTool bounds over bokeh server?

I’m currently creating a figure and serving it over bokeh server. I want to be able to interactively update the axis range when I load a new data set. I can accomplish this by changing the x_range.end value (for example), but when I do this, the plot’s ResetTool will reset the axis range to the original value. What do I need to do to accomplish this? ResetTool doesn’t seem to have any default axis range values associated with it, but I’m sure they must be stored somewhere.

Below is a simplified version of what I want to accomplish. If we serve this via bokeh_server, and click on the ‘zoom’ button, I would like the ResetTool to leave the new axis ranges alone.

from bokeh.plotting import figure, curdoc

from bokeh.models import Button

from bokeh.layouts import column

def zoom():

p.x_range.end *= 1.2

p.y_range.end *=1.2

p = figure(plot_width=300, plot_height=300,

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

p.circle(x=range(11), y=range(11))

b = Button(label=‘zoom out’)

b.on_click(zoom)

curdoc().add_root(column([p,b]))

``

The current ResetTool only ever resets a plot to its original bounds, which are recorded internally on the BokehJS side when the plot is initially displayed. Making it do something different would require new development (please open a feature request on GH if you are inclined). Alternatively you can make a custom extension to do something different, see the user guide for more information about extending Bokeh:

  http://bokeh.pydata.org/en/0.12.3/docs/user_guide/extensions.html

Thanks,

Bryan

···

On Nov 2, 2016, at 2:26 PM, Brian Gerke <[email protected]> wrote:

I'm currently creating a figure and serving it over bokeh server. I want to be able to interactively update the axis range when I load a new data set. I can accomplish this by changing the x_range.end value (for example), but when I do this, the plot's ResetTool will reset the axis range to the original value. What do I need to do to accomplish this? ResetTool doesn't seem to have any default axis range values associated with it, but I'm sure they must be stored somewhere.

Below is a simplified version of what I want to accomplish. If we serve this via bokeh_server, and click on the 'zoom' button, I would like the ResetTool to leave the new axis ranges alone.

from bokeh.plotting import figure, curdoc
from bokeh.models import Button
from bokeh.layouts import column

def zoom():

    p.x_range.end *= 1.2
    p.y_range.end *=1.2

p = figure(plot_width=300, plot_height=300,
           x_range=[0,5], y_range=[0,5])
           
p.circle(x=range(11), y=range(11))

b = Button(label='zoom out')
b.on_click(zoom)

curdoc().add_root(column([p,b]))

--
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/5ea5c82a-3aac-4978-8ac3-660a87f8d528%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for confirming that this is not possible. I opened a github issue. Writing extensions is beyond me, unfortunately (I use bokeh so I don’t have to learn JavaScript!).

For the sake of anyone else who comes across this question, I was able to implement an acceptable workaround by creating a Button labeled “Reset plot zoom” that sets the plot’s axis ranges to a default value that is defined from the plot’s data_source. If I then hide the ResetTool, that does the trick in a pinch.

···

On Fri, Nov 4, 2016 at 11:02 AM, Bryan Van de Ven [email protected] wrote:

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

The current ResetTool only ever resets a plot to its original bounds, which are recorded internally on the BokehJS side when the plot is initially displayed. Making it do something different would require new development (please open a feature request on GH if you are inclined). Alternatively you can make a custom extension to do something different, see the user guide for more information about extending Bokeh:

    [http://bokeh.pydata.org/en/0.12.3/docs/user_guide/extensions.html](http://bokeh.pydata.org/en/0.12.3/docs/user_guide/extensions.html)

Thanks,

Bryan

On Nov 2, 2016, at 2:26 PM, Brian Gerke [email protected] wrote:

I’m currently creating a figure and serving it over bokeh server. I want to be able to interactively update the axis range when I load a new data set. I can accomplish this by changing the x_range.end value (for example), but when I do this, the plot’s ResetTool will reset the axis range to the original value. What do I need to do to accomplish this? ResetTool doesn’t seem to have any default axis range values associated with it, but I’m sure they must be stored somewhere.

Below is a simplified version of what I want to accomplish. If we serve this via bokeh_server, and click on the ‘zoom’ button, I would like the ResetTool to leave the new axis ranges alone.

from bokeh.plotting import figure, curdoc

from bokeh.models import Button

from bokeh.layouts import column

def zoom():

p.x_range.end *= 1.2
p.y_range.end *=1.2

p = figure(plot_width=300, plot_height=300,

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

p.circle(x=range(11), y=range(11))

b = Button(label=‘zoom out’)

b.on_click(zoom)

curdoc().add_root(column([p,b]))

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/5ea5c82a-3aac-4978-8ac3-660a87f8d528%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/yJaAYElkhgM/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/21A800B7-5CA8-4267-B127-E90B350A7B5E%40continuum.io.

Brian F. Gerke, Ph.D.
Principal Scientific Engineering Associate

Energy Efficiency Standards Group

Lawrence Berkeley National Lab

510-486-5973 | ees.lbl.gov

Thanks for confirming that this is not possible. I opened a github issue. Writing extensions is beyond me, unfortunately (I use bokeh so I don't have to learn JavaScript!).

I understand the sentiment. It's definitely on the roadmap to make extensions easily shareable and discoverable, so that the contributions of a few extension writers can be magnified across the entire community. This is really necessary to keep the core library to a maintainable size.

For the sake of anyone else who comes across this question, I was able to implement an acceptable workaround by creating a Button labeled "Reset plot zoom" that sets the plot's axis ranges to a default value that is defined from the plot's data_source. If I then hide the ResetTool, that does the trick in a pinch.

A button callback seems like a perfectly reasonable solution for now, glad it worked out.

Thanks,

Bryan

···

On Fri, Nov 4, 2016 at 11:02 AM, Bryan Van de Ven <[email protected]> wrote:
The current ResetTool only ever resets a plot to its original bounds, which are recorded internally on the BokehJS side when the plot is initially displayed. Making it do something different would require new development (please open a feature request on GH if you are inclined). Alternatively you can make a custom extension to do something different, see the user guide for more information about extending Bokeh:

        http://bokeh.pydata.org/en/0.12.3/docs/user_guide/extensions.html

Thanks,

Bryan

> On Nov 2, 2016, at 2:26 PM, Brian Gerke <[email protected]> wrote:
>
>
> I'm currently creating a figure and serving it over bokeh server. I want to be able to interactively update the axis range when I load a new data set. I can accomplish this by changing the x_range.end value (for example), but when I do this, the plot's ResetTool will reset the axis range to the original value. What do I need to do to accomplish this? ResetTool doesn't seem to have any default axis range values associated with it, but I'm sure they must be stored somewhere.
>
> Below is a simplified version of what I want to accomplish. If we serve this via bokeh_server, and click on the 'zoom' button, I would like the ResetTool to leave the new axis ranges alone.
>
> from bokeh.plotting import figure, curdoc
> from bokeh.models import Button
> from bokeh.layouts import column
>
> def zoom():
>
> p.x_range.end *= 1.2
> p.y_range.end *=1.2
>
>
> p = figure(plot_width=300, plot_height=300,
> x_range=[0,5], y_range=[0,5])
>
> p.circle(x=range(11), y=range(11))
>
> b = Button(label='zoom out')
> b.on_click(zoom)
>
>
> curdoc().add_root(column([p,b]))
>
>
>
> --
> 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/5ea5c82a-3aac-4978-8ac3-660a87f8d528%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/yJaAYElkhgM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [email protected]ntinuum.io.
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/21A800B7-5CA8-4267-B127-E90B350A7B5E%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
Brian F. Gerke, Ph.D.
Principal Scientific Engineering Associate
Energy Efficiency Standards Group
Lawrence Berkeley National Lab
510-486-5973 | ees.lbl.gov

--
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/CAN%3D17gSWNRWyLwJVU4xRnWYPBEQaTGVzqHniZ-vsrONciGR9jA%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.