I’m working on an application that works with different SI units. For that application, I need to display units as bokeh labels in plots. However, I’m having issues with some of the symbols I need, and I’m not sure if the problem is in my usage of the library, or if it’s a bug with bokeh or MathJax.
In particular, I need a non-italic greek lowercase mu (μ) and a uppercase A with an overring (Å), but have been unable to get those. They are rendered almost correctly, but appear very small and on top of the other letters.
Here’s a minimal working example of everything I’ve tried so far:
from bokeh.plotting import figure, curdoc
from bokeh.models import Label
p = figure(
width=550,
height=250,
x_range=(-50, 500),
y_range=(-125, 125),
)
label = Label(
x=0,
y=0,
text=(
r"$$\upmu\mathrm{N}\mathrm{m}$$ "
r"$$\mbox{µ}\mathrm{N}\mathrm{m}$$ "
r"$$\text{µ}\mathrm{N}\mathrm{m}$$ "
r"$$\mbox{µ}^\circ\mathrm{C}\Omega\mbox{Å}\%'''^\circ{\hbar}E_\mathrm{h}$$ " # These are all the special characters I need. Most of them do work like this.
),
)
p.add_layout(label)
curdoc().add_root(p)
Well the live demo on the MathJax site seems to render things properly (see below). That said, AFAIK all we do is immediately pass off LaTeX strings to MathJax to render so I am not sure how Bokeh could be causing any issue, either. It’s possible that Bokeh is using an old version of MathJax that had some bug in the past, in which case it might be as simple as updating to a newer MathJax version. But in any case it will take some investigation, so all I can suggest is to make a GitHub Issue with all these details. (Edit: and please, always include all relevant version information in any issue or help request)
OK a little more digging: Bokeh currently uses MathJax 3.2.2. Here is a pure HTML snippet that shows your content being mis-rendered, albeit in a different way, by MathJax 3.2.2.