Search code examples
pythonbokeh

Formatting log axis labels with proper superscripts in Bokeh


This is, admittedly, a minor annoyance. When using log scale axes, Bokeh formats the tick labels as "10^1" instead of "101"

enter image description here

Is there any way I can modify this so it uses the superscript?

Alternately, I would like to label with JUST the exponent. Either way looks much nicer than how it is now.


Solution

  • As of Bokeh 2.2, passing y_axis_type="log" to figure automatically displays exponents on log axes in a nice way:

    enter image description here

    For more complicated scenarioBokeh 2.4 also adds further support for LaTeX (and MathML) to some elements in Bokeh. Currently, you can use LaTeX on axis labels, tick labels, div widgets, and paragraph widgets. LaTeX support for more elements should be added soon. For more information about the new math text feature and how to use them, see the Bokeh 2.4 release blogpost, the new blackbody radiation example, and the Bokeh user guide!

    enter image description here