最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Cannot print Noto Color Emoji characters in titles and labels of matplotlib plots - Stack Overflow

programmeradmin0浏览0评论

Originally when utilising the builtin font, DejaVu Sans, I would get a warning while saving the graphs, saying: "UserWarning: Glyph 127957 (\N{CAMPING}) missing from font(s) DejaVu Sans."

Since manually adding the Noto Color Emoji ttf file to the ttf folder within the site packages of my venv (full path at the bottom), deleting the matploblib cache and forcing it to reindex its fonts, this warning has gone away (and I have confirmed it can find the font). As you can see below I have set both default font families, but in the reproducible example I only get whitespace or the emojis that are still present in DejaVu Sans. I have also tried setting the font family parameter within the set_title call itself, but no luck. I also tried just using Noto Color Emoji but not only does it not contain the standard alphabet, but it also still didn't render the emojis.

I also tried using a Cairo backend since I read somewhere that would resolve this issue, but nothing changed. This appears to be an incompatibility between matploblib and this particular font but I am sure I am missing something.

import matplotlib as mpl
import matplotlib.pyplot as plt

mpl.rcParams.update({
    'font.family': ['Noto Color Emoji', 'DejaVu Sans'],
})

fig, ax = plt.subplots()
ax.set_title('a 
发布评论

评论列表(0)

  1. 暂无评论