Skip to content Skip to sidebar Skip to footer

How To Modify Categories Text Size In Bokeh Bar Charts?

I am unsuccessfully trying to modify the size of the text of the different categories (text highlighted in yellow) in a BOKEH bar-chart. I would be really grateful if somebody kno

Solution 1:

The trick is to modify the text size of the CategoricalAxis which is below the figure object (usually first item at position 0).

To modify the text size for groups, use this line.

p.below[0].group_text_font_size = '13px'

In the same way you can set multiple other styling options, like the axis_label_text_font_size or the major_label_text_font_size and many other. To see how it works, look at the example below.

Demonstration

Following the example from bokeh about Handling Categorical Data the output looks like this:

before text size modification

Now you can do some changes for the text below the x-axis.

p.below[0].group_text_font_size = '16px'
p.below[0].group_text_font_style = 'normal'
p.below[0].group_text_color = 'black'
p.below[0].major_label_text_font_size = '14px'
p.below[0].major_label_text_color = 'black'

This will set

  1. a new font size for groups ('16px') and labels ('14px'),
  2. a new font color for groups and labels (here 'black') and
  3. a new font style to the groups (here 'normal').

The figure looks now like this: after text size modification

Post a Comment for "How To Modify Categories Text Size In Bokeh Bar Charts?"