Hiragana charachters in Matplotlib

I am trying to render Hiragana letters in my plot, but i keep getting a warning that the glyph cannot be found.

RuntimeWarning: Glyph 12367 missing from current font.font.set_text(s, 0, flags=flags)

I tried to set the font to Arial but it still does not work, even thought it is rendered properly in HTML.

I don’t understand why Matplotlip is not rendering the characters, even thought they are supposed to be there for Arial.

Actually if you use e.g. Chrome’s “inspect” functionality you should see that Chrome had to use a separate font to render the hiragana – on my computer, it’s WenQuanYi Zen Hei:
Unfortunately we don’t support this kind of auto-substitution yet, see e.g. https://github.com/matplotlib/matplotlib/issues/18883.

1 Like

Thanks, in my case it was “Microsoft YaHei”. Switching to it did the trick for me.

plt.rcParams['font.sans-serif'] = "Microsoft YaHei" 
1 Like

https://matplotlib.org/tutorials/text/text_props.html#text-with-non-latin-glyphs may be a useful reference for how to find the correct font.