1

In bokeh you can set the theme easily:

from bokeh.io import curdoc
curdoc().theme = "caliber"

I am not sure how to simply get a string readout of the current theme. I tried curdoc().theme and that returned <bokeh.themes.theme.Theme at 0x21637f022c8>. Just using printing, __repr__, and __str__ returned similar results. Simply inspecting the output of dir(curdoc().theme) didn't reveal any obvious getters I might try (but I'm probably missing something obvious).

eric
  • 7,142
  • 12
  • 72
  • 138

1 Answers1

2

Theme does not contain that information, but you could try:

from bokeh.themes import built_in_themes

theme = curdoc().theme
theme_name = next(k for k, v in built_in_themes.items() if v is theme)
Tiger-222
  • 6,677
  • 3
  • 47
  • 60
  • 2
    Just to elaborate on this: themes are only collections of new default property values (a Theme object). They do not have any intrinsic name at all. There is, externally, a mapping from some standard names to some standard Theme objects for convenience, but *not* the converse (what you are asking for) – bigreddot Apr 25 '21 at 07:05
  • Interesting. Is the default theme one of the named themes (this was actually what I was trying to get)? Basically my question was confused, sort of like asking for the name of a `SimpleNamespace` object, when such objects are just a collection of properties (and if such a collection happens to have a name it is it solely for convenience they aren't really important or essential). – eric Apr 26 '21 at 13:28