The color format adopted by the bokeh sections

In many Bokeh examples (for example, unemployment graph , and periodic table ), I see that the rect construction primitive gets color from ColumnDataSource from the HTML view:

eg:.

 .... 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 rect documentation , I donโ€™t see a parameter for color (note that you are allowed to pass line-properties "and" fill-properties ", but none of them accepts color as a parameter)

Most importantly for this question, is there any other way than HTML to specify colors for Bokeh plots? Ideally, I would like to specify colors using the color palettes created by seaborn .

+5
source share
1 answer

color is an argument of convenience to graph glyph methods that simultaneously set both line_color and fill_color . These are factual arguments if you prefer to use them for explanation or to establish them yourself.

There is also a LinearColorMapper object that you can customize using one of the palettes in bokeh.palettes or with your own custom color sequence. You can use this from python to map data to a color list for ColumnDataSource .

Please note that in the upcoming release (perhaps 0.8) you will be able to specify the palette name / colormapper + column for the color arguments (or line_color or fill_color ), and then the colors will be matched on the client (instead of explicitly sending over a large list colors)

+4
source

Source: https://habr.com/ru/post/1209846/


All Articles