Is there a way to change the alpha of the glyph in a Bokeh legend?
Take this example. I have the alpha of the lines in my plot set to 0.1
, but the line glyph in the legend mirrors this alpha value also.
You can change the alpha of everything else in the legend (i.e border, text, background) but not the glyph?!
This is frustrating as it means I can't tell which colour is associated with which label (if the alpha is set low).
import numpy as np
from bokeh.plotting import output_file, figure, show
x = np.linspace(0, 4*np.pi, 100)
y = np.sin(x)
alpha = .1
output_file("legend_background.html")
p = figure()
p.line(x, y, legend="sin(x)", line_alpha=alpha)
p.line(x, 2*y, legend="2*sin(x)",
line_dash=[4, 4], line_color="orange", line_width=2, line_alpha=alpha)
p.line(x, 3*y, legend="3*sin(x)", line_color="green", line_alpha=alpha)
p.legend.location = "top_right"
show(p)
It would be great to just be able to do something like p.legend.glyph_alpha = 0.9
.
To clarify: In the actual use case this relates to, I can have upwards of 100,000 lines (i.e 30,000 from one label and 70,000 from another) and therefore I want to be able to set the alpha of the lines in the plot very low to look for overlapping trends etc.