Dark mode plotting for RISE presentations

Hi, as mentioned in a tweet I’d like to have a dark mode for my bokeh plots.
To be precise I’d like to have them on a RISE jupyther notebook.
Is there a simple way to use a dark mode? A simple tutorial I can use to get there?

Bokeh themes can be implemented using **curdoc().theme = 'dark_minimal'**. For custom themes, the below example should help you.

from bokeh.io import curdoc
from bokeh.io import show, output_notebook
from bokeh.models import CategoricalColorMapper, ColumnDataSource, FactorRange
from bokeh.plotting import figure

output_notebook()
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 4, 2, 4, 6]

p = figure(x_range=fruits, plot_height=250, toolbar_location=None, title="Fruit Counts")
p.vbar(x=fruits, top=counts, width=0.9)

p.y_range.start = 0
p.border_fill_color = "black"
p.title.text_color = 'white'
p.axis.axis_line_color = None
p.axis.major_tick_line_color = None
p.grid.grid_line_color = None

#Use curdoc().theme = 'dark_minimal' for inbuilt theme or use custom
#theme as below

curdoc().theme = Theme(json=yaml.load("""
        attrs:
            Figure:
                background_fill_color: "black"
                outline_line_color: black
                toolbar_location: above
                height: 500
                width: 800
            Grid:
                grid_line_dash: [6, 4]
                grid_line_color: black
    """))
show(p)

More details here: Custom Themes

1 Like