[BUG] Incorrect legend color with different glyphs with same CDS and a CDSView
See original GitHub issueSoftware 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve left a note in the other issue to make sure to validate the above analysis when the other issue is addressed.
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.