New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Behaviour of automated padding for ranges is inconsistent #9724
Comments
@Tikonderoga can you please try and report back with 2.0.0rc1 (available on pypi or bokeh/dev channel on anaconda.org) Please note the starting with 2.0 hiding glyphs in the legend will remove them from automatic ranging computations (often requested feature) Also, AFAICT, a summary of the issue is this, please confirm:
|
@bryevdv Sorry, as I mentioned, it's weird issue and my description was lacking. Issue (exists for all versions of Bokeh?):
In Bokeh > 1.4.0 is manifests itself in a case when p.y_range.only_visible = True: Y-range is small, all works fine: Y-range is large, breaks when 1 line visible: I think there's something wrong in a way how automatic padding is being calculated - it's looks like it's not taking size of range into consideration. And when you have only one line visible out of many, same code path is being used. |
@Tikonderoga I have a suspicion, but have not yet been able to look into it. You could check out the BokehJS for DataRange1d in the mean time, if you like. My suspicion is this:
If this is actually the case, I am not sure I could conclude that the observed behavior is not, in fact, the correct behavior. I would not be in favor of adding magic, implicit special cases. So what could be done? Some ideas:
|
Looking quickly at the code, I do believe this is the case, and as I mentioned above this behavior not inconsisten, it is in fact completely consistent: the padding is always a percentage of the computed min/max range, even if that range is zero. For now, changing |
@bryevdv Look at the image below. For all lines, at any Y-value, computed min/max range would be zero. Why there's padding added for lines A, B and C, but not for D? Also, which part of Bokeh code should I look into? |
It's not really possible for me to speculate with just the images. Are there other invisible glyphs? What is the configuration of the data range? For that matter, are the "ABCD" labels or text glyphs, or were they added outside Bokeh after the fact completely? Code for what you have above would help clarify.
Yes that's the main file of interest. The range will ask any available renderers for their bounds (and then union them together), so there's also some possibility that the bounds computation in the |
Sure, I'll provide code and a lot of test cases where padding (both manual and automatic) appears to be broken. There will be multiple comments Case 1.
What's wrong? |
@Tikonderoga That's perfect I can run that and actually probe what the JS is doing. FYI I think you could just pass e.g. |
Looking at those now it looks possibly like the padding is always 1, which simple shows up very tiny on the scale of the last plot. |
Case 2: Auto-padding works correctly!
Case 3 : Auto-padding broken with y_range.start = 0
That's an interesting one: all charts appears to be okay, even the last one, but one in the middle is not. |
Case 4: Playing with range_padding. Not working for straight lines!
If computed range for line is 0, manual padding not working at all. |
Case 5: manual padding with non-straight lines:
|
Case 6: range.only_visible = True, auto-padding not working when only 1 line is visible
For straight lines auto-padding stops working when only 1 line is visible. |
Case 7: same as case 6, but lines are not straight
Auto-padding not working for cases where only 1 line is visible even if line is not straight. |
Case 8: Manual padding, percentages
This one also broken for case where 1 line is visible (probably because computed range for that case is 0). |
Case 9: Manul padding, percentages, not straight lines.
Finally, we have padding in all cases. But it's not perfect (it's too large for a case when all 3 lines are visible). |
Overall, I think computed min/max range should acknowledge the fact what start or end of the range is pinned. For example, is computed range for line is (Ymix:Ymax), but y_range.start = Ys, computed range should be (Ys:Ymax) or even (min(Ymin, Ys): Y:max). I think it would solve all the issues above. |
Currently the implementation completely ignores explicitly set |
My personal approach to this is as follows:
This will make sure that you always have the most recently built bundles and debugging experience in jlab is the most efficient. Another personal preference is not to use jlab for bokeh development, as it's usually more trouble than it's worth. |
|
Thanks,
does the trick. |
And follow-up question: is there any instructions how to contribute to bokeh source code? |
@Tikonderoga yes exactly PRs from forks are the standard way to proceed |
Exists in Bokeh from 0.13.0 till 1.4.0
Tested on Windows 10 and Ubunto 16.0, on Firefox and Chrome (most recent versions).
That's the weird bug, so explanation will be rather long.
Example 1:
That produces pretty looking chart:

Automatic padding added a little bit of space between horizontal line and top end of the chart, so line is clearly visible.
Example 2:
With line located at Y=300, there's no automatic padding added, so line located directly on the border of the chart.
One can argue, it can be easily fixed bu using customized y_range, but manually setting y_range bounds makes it hard to use new feature from 1.4.0 (#9144):
Example 3 (only works in Bokeh 1.4.0):
Now we are using automated Y-range scaling.
All lines are clearly visible no matter how many lines we have hidden:
or
But if we change Y-values for lines back to 300...
Example 4 (only works in Bokeh 1.4.0):
For 3 lines it works fine:
For 2 lines it works fine:
But with only 1 line visible automated padding not working again:
What I would expect?
I would expect to see similar gap between red line and top boundary of the chart, as I see for blue and green lines.
Why it's important?
Without callbacks there's no way to change y_range for the chart when certain lines became hidden and visible. As far as I understand, #9144 was supposed to provide simple way to do so, but since automated padding not always working the way you expect it to work, it's almost useless.
The text was updated successfully, but these errors were encountered: