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] Incorrect legend color with different glyphs with same CDS and a CDSView

See original GitHub issue

Software version info

  • python: 3.6.10
  • bokeh: 2.0.1
  • OS: macOS 10.14.6

Description of expected behavior and the observed behavior

I’m plotting circles and segments with different colors from the same CDS. All circles are plotted, but only some segments are plotted, using a CDSView.

I expect the legend to show the correct symbol and color, but one of the colors doesn’t match the source.

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

from bokeh.plotting import figure
from bokeh.models import CDSView, ColumnDataSource, BooleanFilter
from bokeh.io import show

p = figure()

ds = ColumnDataSource(data={
    'color': ["blue", "red"],
    'x0': [0, 0],
    'y0': [1, 0],
    'x1': [1, 1],
    'y1': [1, 0]
})

# I also tried with an IndexFilter and CustomJSFilter and got the same result
view = CDSView(source=ds, filters=[BooleanFilter([False, True])])

p.circle(
	x='x0', y='y0',
	color='color',
	legend_field='color',
	source=ds)

p.segment(
	x0='x0', y0='y0', x1='x1', y1='y1',
	color='color',
	legend_field='color',
	source=ds,
	view=view)

show(p)

Stack traceback and/or browser JavaScript console output

No logs in python or the JavaScript console output.

Screenshots or screencasts of the bug in action

Note the red line across the blue dot in the legend

image

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Apr 7, 2020

I’ve left a note in the other issue to make sure to validate the above analysis when the other issue is addressed.

0reactions
bryevdvcommented, Apr 8, 2020

And actually looking in to things a bit more closely I think we will be limited in what we can do. Basically all renderers that specify the same legend_field are grouped together on the Python side. We can probably make the BokehJS side respect one view for one renderer pretty easily, and that is how I will proceed for the other issue. But it’s not even clear what the correct behavior should be when different renderers in the same legend map out to different groups. In the general case there would be no guarantee there is even any overlap like above. This just wildly breaks very deep assumptions about how legends are expected to be, and has never be defined, and I think making it do anything well-defined would be a rather heavy lift for a rather obscure use case, i.e. not justifiable in terms of time/effort, given other priorities. I think in this situation it would be better to construct a legend manually however you want it using legend items with explicit indices.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this legend going into party mode rotating across ...
I've set up a legend and it all works fine until I start using a slider to filter results and it suddenly thinks...
Read more >
selection across multiple glyphs with an interactive legend ...
the orange and green points are not actually selected, they just don't change color to the gray color. If you were to use...
Read more >
Using the ColumnDataSource Object - Real Python
This video covers Bokeh's ColumnDataSource object. The ColumnDataSource is foundational in passing the data to the glyphs you are using to visualize.
Read more >
Bokeh legend - MilanoIngegneria
They help us to differentiate between different glyphs used in a plot. ... an entry in a Legend Bokeh can be used to...
Read more >
color legend, Information tab and spreadsheet giving incorrect ...
Third bug. Sort on TEMPK. Notice that everything is zero. This is wrong, the outside of the cone should be 293.9 degrees! Same...
Read more >

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