Python 如何将下载的truetypefont添加到matplotlib.font#u manager';什么是ttflist?

Python 如何将下载的truetypefont添加到matplotlib.font#u manager';什么是ttflist?,python,python-3.x,matplotlib,networkx,Python,Python 3.x,Matplotlib,Networkx,我有一种奇特的truetype字体,我希望我的networkx节点标签(中文字符)能够显示在这种字体中 之后 我用 获取我以后可以在中使用的可用字体列表 networkx.draw(myGraph, font_family = "someFontFromTheList"). 这是我绘制图表的方式: import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() G.add_edge("火", "水") nx.draw(

我有一种奇特的truetype字体,我希望我的networkx节点标签(中文字符)能够显示在这种字体中

之后

我用

获取我以后可以在中使用的可用字体列表

networkx.draw(myGraph, font_family = "someFontFromTheList").
这是我绘制图表的方式:

import networkx as nx
import matplotlib.pyplot as plt

G = nx.Graph()
G.add_edge("火", "水")
nx.draw(G, with_labels = True, font_family = "TakaoPGothic", node_size = 1600, font_size = 25, node_color = "lightblue")
plt.savefig("graph.png")
“Takaop哥特式”字体是我在列表中找到的唯一包含CJK字符的字体。通过使用它,我至少得到了


现在我如何在
/path/to/my/font.ttf
中使用自己的字体?我想办法是以某种方式将其添加到上述matplotlib的字体列表中?

好的,我自己这样解决了这个问题:

现在的图表如下所示:


.

通常,您只需在操作系统中安装字体,以便matplotlib可以使用它。matplotlib的字体列表是从系统上可用的字体生成的。有趣的是,情况似乎并非如此。我的系统上预装了一个名为“Noto CJK”的CJK字体系列,它没有显示在matplotlib的字体列表中。从外部很难分辨。matplotlib中的字体已经存在很多问题。通常通过清除fontcache来解决这些问题。可能这也取决于操作系统。我将阅读如何清除字体缓存。谢谢我是Xubuntu 16.04 btw。为了将来的参考:如果您有更多的问题信息,请。人们往往不看评论。
networkx.draw(myGraph, font_family = "someFontFromTheList").
import networkx as nx
import matplotlib.pyplot as plt

G = nx.Graph()
G.add_edge("火", "水")
nx.draw(G, with_labels = True, font_family = "TakaoPGothic", node_size = 1600, font_size = 25, node_color = "lightblue")
plt.savefig("graph.png")