bokeh: Zooming out with bound ranges doesn't zoom all the way

Bokeh version: 0.12.4

  1. set bounds='auto' on x_range and y_range range
  2. zoom in with mouse pointer near the lower left corner of the plot
  3. zoom out with mouse pointer near the upper right corner of the plot

Observed behavior: Plot is zoomed in just fine, but zooming out doesn’t bring the plot to the same state as before apparently because zooming in doesn’t try to move plot at all

Expected behavior: The plot moves as to both be inside the specified bounds and to be zoomed out up to the initial state when zooming out is no longer possible without breaking bounds contstraint.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 3
  • Comments: 16 (15 by maintainers)

Most upvoted comments

In case people subscribed to this issue didn’t receive any notification - a flag to change the default behavior has been added in #7683.

@bryevdv I just stumbled upon this again. I don’t think the reset tool is for this, at least because it does some other things as well. Another reason is that it may be really hard, if not impossible with the current state of things, to set up the desired state as the initial one.

I would suggest adding centered_zoom_in and centered_zoom_out parameters to WheelZoomTool. By default, they’re True and represent current behavior. Setting them to False would remove center argument for scale_range function for the appropriate case of zooming in or out.

I would argue that’s what the rest tool is for

Cursor-centered zooming works great, but the constraint should be lifted when unsatisfiable if that means honoring the API user’s specified figure bounds and visualization user’s request of zooming out.

Have this example:

import numpy as np
from bokeh.io import show
from bokeh.plotting import figure

N = 10000
x = np.arange(N)
y = np.cumsum(np.random.random(x.size) - .5)

p = figure(plot_height=800, plot_width=1000, tools='xpan,xwheel_zoom',
           active_scroll='xwheel_zoom', active_drag='xpan')
p.line(x, y)

p.x_range.bounds = (0, N)
p.x_range.start = 0
p.x_range.end = N

show(p)

Do zoom in on the far right of the chart. Now zoom back out and see that that’s working. Now zoom back in on the far right of the chart, but then pan the chart slightly. Now try zooming out again completely (without panning to the (supposed) plot center after each zoom step).

Compare this to how Highcharts does it: https://jsfiddle.net/highcharts/6etwu5b4/

It is as clear as day this could be made a slight bit more user-friendly.

Please reopen as a feature request.