pythonbokeh

Bokeh Bar Chart - how to remove separator lines (x axis with nested categories)


I've successfully created a Bokeh bar chart with nested categories by following the examples at the official bokeh site (https://docs.bokeh.org/en/latest/docs/user_guide/basic/bars.html)

However, despite a thorough review of all the styling attributes and how they work, I simply cannot find the attribute name or location for a specific part of the visual-- the light grey lines appearing between the nested categories on the x-axis. I'm familiar with how to modify the visuals in my python code that generates the bar chart: the issue is that I can't figure out what attribute, if any, pertains to these specific lines!

Please see the included image: I have circled in red one of the (multiple) separation lines that I do not want to display. Why? Because in my bar chart, the labels (e.g. '2015' in the example image) are much longer words, which results in them overlapping with the vertical separators, resulting in a messy and cluttered display.

unwanted vertical separators


Solution

  • In your example a CategoricalAxis is created which has the parameter separator_line_color which can be a color or None.

    If you want to have no separator line you can add

    p.below[0].separator_line_color = None
    

    to the code.

    Please be carful, because p.below[0] adresses the first element of the list of elements which are below the figure. This is usually ordered by the order of the creation of the elements. If there is more thant one element, you have to find the correct index by yourself.

    The result should look like the figure below

    CategoricalAxis with no seperation line

    Comment:

    Other attributes you can use to get the same result are

    p.below[0].separator_line_alpha = 0
    p.below[0].separator_line_width = 0