Need help with themes -- can't set theme values for individual axes and grids

I like the idea of using themes to override default behavior. I’m using them to reduce repetitive code. I’m a bit surprised that I couldn’t find a collection of pre-made themes like ggplot2 has in R.

I appreciate the Bokeh theme documentation here:

and this S.O. post showed me how to actually USE themes:

I created default “themes” for the Grid, Axis, Title, Figure, Legend – and those work like a charm! But I can’t figure out how to control the settings for xaxis and yaxis, xgrid and ygrid. Because of this I can’t include f.yaxis.major_label_orientation = “vertical” in the theme.

And I can’t find examples anywhere . . . maybe I’m one of the only people doing this? Can anyone point me in the right direction?

These are the important excerpts from my code:

import bokeh_theme

f = figure(x_range=axes_values,




style the title

f.title.text = “Title of Plot”

f.yaxis.axis_label = “Y Axis Label”

f.xaxis.axis_label = “X Axis Label”“xvalues”,







from import curdoc

from bokeh.themes import Theme

from bokeh.palettes import YlGn

text_font = ‘times’

palette = YlGn.get(9)

curdoc().theme = Theme(json={‘attrs’: {

apply defaults to Figure properties

‘Figure’: {

#‘background_fill_color’: ‘#EFE8E2’,

‘background_fill_color’: palette[6],

‘toolbar_location’: ‘above’,

‘outline_line_color’: palette[0],

‘min_border_right’: 10,

‘min_border_left’: 10,


apply defaults to Title properties

‘Title’: {

‘text_color’: palette[0],

‘text_font’: text_font,

‘text_font_size’: ‘2em’,

‘align’: ‘center’,


apply defaults to Axis properties

‘Axis’: {

‘major_tick_in’: None,

‘minor_tick_out’: None,

‘minor_tick_in’: None,

‘axis_line_color’: palette[4],

‘major_tick_line_color’: palette[4],

‘major_label_text_font_size’: ‘1em’,

‘major_label_text_color’: palette[0],

‘axis_label_text_font_size’: ‘1.5em’,

‘axis_label_text_color’: palette[0],

‘axis_label_text_font’: text_font,


‘Grid’: {

‘grid_line_alpha’: .3,

‘grid_line_color’: palette[0],


‘yaxis’: {

‘major_label_orientation’: ‘vertical’, #doesn’t work – ignores yaxis portion altogether.

‘major_label_text_color’: ‘orange’,


apply defaults to Legend properties

‘Legend’: {

‘location’: ‘top_left’,

‘background_fill_color’: None,

‘background_fill_alpha’: 0.3,

‘label_text_font’: text_font,

‘label_text_color’: palette[0],

‘label_text_font_size’: ‘1em’