Reputation: 10184
For a complex scatterplot with 20k+ points I need to set the fill_alpha of the scatter points to a low value, say 0.2.
How can I set the fill color in the legend to full opaque (aka not transparent)?
Example code:
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource
p = figure(plot_width=640, plot_height=320)
x = [10]
y = [10]
color = ["blue"]
category = ["Lorem Ipsum"]
source = ColumnDataSource(dict(x = x, y = y, color=color, legsrc=category))
p.scatter(x="x", y="x", fill_alpha=.2, size=100, color="color",
line_color=None, marker="circle", source=source, legend="legsrc")
show(p)
Upvotes: 3
Views: 1969
Reputation: 11
For sure I'm out of time, but maybe could still help others. I solved this by making two different plots: the first with color mapping and no legend, the second with a single color, with legend option and size=0 (so it is not displayed)
In your case:
p.scatter(x="x", y="x", fill_alpha=.2, size=100, color="color",
line_color=None, marker="circle", source=source)
p.scatter(x="x", y="x", size=0, color="lightgrey",
line_color=None, marker="circle", source=source, legend="legsrc")
Upvotes: 1
Reputation: 34568
As of Bokeh 1.0.2. this is not possible. Legend items always mirror the visual properties of the glyph they represent exactly, including alpha. If you would like to discuss the possibility of adding some mechanism to override legend glyph properties, the next step would be to make a detailed feature request issue on GitHub.
Upvotes: 1