Student Student - 3 years ago 272
HTML Question

How I can change the border color of the bars in a bokeh histogram?

Objective: to change the border color of a Bokeh histogram bar from default black.

Below is an actual snippet from a Bokeh histogram:

enter image description here

The black lines highlighted above are what I am aiming to change to any other color besides black.

Any help would be appreciated.

Answer Source

You haven't provided any code (you should always provide sample code when asking for help). So it's not actually possible to knowk whether you are using the old (and deprecated and removed) bokeh.charts.Histogram or not. If that is the case, first things first: stop using it immediately. The old bokeh.charts API is completely unmaintained at this point. It is a dead end.

Either way, you can create a histogram in Bokeh using the stable ad supported bokeh.plotting API, in which case styling is styling is accomplished in the same general manner for all glyphs, as described in the User's Guide documentation.

Here is a complete example:

from import output_file, show
from bokeh.plotting import figure
from bokeh.sampledata.autompg import autompg as df

from numpy import histogram, linspace

x = linspace(0,250,200)

p = figure(plot_height=300)

hist, edges = histogram(df.hp, density=True, bins=20)
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], alpha=0.4,

       # same technique and properties for every Bokeh Glyph
       line_color="red", line_width=2)



enter image description here

Alternatively, if you are looking for a very high level API with a built in "Histogram Plot" type function, check out out HoloViews: It is a very high level API built on top of Bokeh and is actively maintained by a team of people.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download