Zoom In/ Out to limit within integer values


The box zoom or any zoom feature in bokeh takes the bar chart in negligible amounts. I was wondering if there is a way to limit the zoom in/out to integer values so it doesn’t go out of range?

Like For e.g I am using the bar chart feature of Bokeh, and my x-range is from 0-700. However, when I zoom in, it shows values in floating numbers like 450.464646464646 etc. Is it possible to limit it till integers only?

I have also asked the same question in stack overflow for a better reach.

Thanks in advance,

@sumodhnair If you must cross-post to other forums (e.f. Stack Overflow) please always include the cross-links in all places, so that an answer in any one place is always reachable everywhere.

There is nothing built-in that would limit the zoom in this way. However, I am questioning if this is actually your goal Are you simply wanting to have different/cleaner tick labeling on the axis (regardless of the bounds)?

@Bryan Thanks for your response. I have updated the question with the link to Stack, and vice versa.

Yes, that’s the goal. The reason being, my x-range only has values in the range of 0-700.
So the idea is to limit the zoom/pan in a way that it won’t go beyond say 450 if it were floating numbers like for e.g 450.2 that were to follow next. Also, shouldn’t pan after 700 etc.

Is it possible to maybe somehow limit it, so that the zooming is blocked when the next set is floating numbers?

@sumodhnair I am afraid some of your desription does not make sense to me, e.g. if the range is 0-700 how would it also make sense to restrict panning (zooming?) to greater than 450 (as the start? the end?)

So instead all I can do is offer some general pointers. Ranges support various bounds, both in absolute start/end values or in min/max intervals. All of those are documented here:


You can also control the what tick locations are chosen for ticks by configuring a ticker:


And the formatted appearance of ticks (e.g. number of decimal places, prefixes,etc) by configuring a tick formatter:


@Bryan Thank you for the response. I am afraid my question wasn’t clear. What I am trying to achieve is to stop the progression of ranges of x axis to go in floating numbers.
For more clarity I am attaching images showing the the zoom process step by step.
Step 1:

(This is my default zoom level)

Step 2: I have now selected an area from range 440-480

(2nd level)
Step3: I have now selected an area from range 460-470
(3rd level)

I want to stop the zoom level here since the gap between the x_range is getting to floating numbers. What I’d instead like to achieve is to have the maximum zoom level separation to be 1. Is that possible?

Adding 4th level to show that the separation gets more in minuscule numbers

Seems like the range propertymin_interval described on the first linked page above is what you want. If not, I don’t think there is any other configuration that is relevant.