question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] BoxAnnotation doesn't respect fill_color=None

See original GitHub issue

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

Bokeh 2.0.0 | Python 3.7 | Firefox 74.0 | Windows 10 build 16299.1747

Description of expected behavior and the observed behavior

Expected behavior: Glyphs generally support turning off fill by supplying a fill_color value of None. Would expect the same from BoxAnnotation.

Observed behavior: BoxAnnotation (and maybe others? haven’t tested) instead appears to have a white fill with a low (but nonzero) alpha under these conditions. Setting fill_alpha to zero has the desired effect, but this is not my standard usage pattern for turning off fill, and it should probably be consistent anyway.

Complete, minimal, self-contained example code that reproduces the issue

import bokeh.plotting
import bokeh.models

bokeh.plotting.output_file("box_annotation_test.html")

fig = bokeh.plotting.figure(width=500, height=500, x_range=[0, 3], y_range=[0,3])

fig.circle(x=[1, 1, 2, 2], y=[1, 2, 1, 2], size=100, line_color=None, fill_color="Red")

ba = bokeh.models.BoxAnnotation(bottom=1, top=2, left=1, right=2, line_color="Blue",
                                line_dash="dotted", fill_color=None)
fig.add_layout(ba)

bokeh.plotting.save(fig)

Screenshots or screencasts of the bug in action

bokeh_plot

The BoxAnnotation is drawn between the centers of the red circles. Notice the “notches” of paler red where the box intersects them.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mattpapcommented, Apr 6, 2020

Line and fill visuals should be considered independently, the same way as glyphs work. Essentially you have to replace:

this.visuals.fill.set_vectorize(ctx, i)
ctx.fill()

with

if (this.visuals.fill.doit) {
  this.visuals.fill.set_vectorize(ctx, i)
  ctx.fill()
}

and similarly change line visuals.

The tricky bit is that annotations have both canvas and CSS modes. This code only handles to former and you will have to figure out the later.

1reaction
bryevdvcommented, Apr 3, 2020

Right, it’s currently not explicitly checking for null condition on the JS side, so it is rendering “null” color with a default opacity of 0.4 (whatever canvas defines that to do). For now you can add fill_alpha=0 as a workaround:

Screen Shot 2020-04-03 at 1 48 25 PM

Since it should be a simple fix and since there a a workaround I will leave it for now a Good First Issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found