In many Bokeh examples (e.g. the unemployment chart, and the periodic table), I see that the plotting primitive rect
receives color
from ColumnDataSource
from an HTML representation:
e.g.:
....
colors = [
"#75968f", "#a5bab7", "#c9d9d3", "#e2e2e2", "#dfccce",
"#ddb7b1", "#cc7878", "#933b41", "#550b1d"
]
source = ColumnDataSource(
data=dict(month=month, year=year, color=color, rate=rate)
)
p.rect("year", "month", 1, 1, source=source,
color="color", line_color=None)
However, looking at the documentation of rect
, I don't see a parameter for color
(note that you are allowed to pass "line-properties" and "fill-properties" parameters, but none of them accept color
as a parameter)
Most importantly for this question, is there a different way, other than HTML, to specify colors for Bokeh plots? Ideally, I would like to specify colors using the color palettes generated by seaborn
.
The bokeh. plotting API is Bokeh's primary interface, and lets you focus on relating glyphs to data. It automatically assembles plots with default elements such as axes, grids, and tools for you.
You can hide the lines by setting their grid_line_color to None .
color
is a convenience argument to the plot glyph methods that sets both line_color
and fill_color
at the same time. Those are the actual arguments, in case you'd rather use them for explicitness, or need to set them independently.
There is also now a LinearColorMapper
object that you can configure with one of the palettes in bokeh.palettes
or with your own sequence of colors. You can use this from python to map data into the list of colors for the ColumnDataSource
.
Note that in an upcoming release (probably 0.8) you will be able to specify a palette/colormapper + column name for the color
(or line_color
or fill_color
) arguments, and then the color mapping will happen on the client (instead of having to send over the possibly large list of colors explicitly)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With