Problem Description
Hello everyone, when we use networkx to display Chinese, we will find that Chinese cannot be displayed.
Solution
- Download the font in the attachment;
- Execute in jupyter notebook
import matplotlib
print(matplotlib.__path__)
Find the path of matplotlib, and then cd to this path. After cd reaches this path, continue cd, cd to mpl-data / fonts / ttf this path. Then DejaVuSans.ttf
this document we have just replaced under the document, then try to find the font file matplotlib call, really found it. Because matplotlib calls the DejaVuSans.ttf font file by default, as long as you copy a font file you want from Windows and replace DejaVuSans.ttf, there is no problem.
$ mv SimHei.ttf nx.draw(city_graph, city_location, with_labels=True, node_size=10).ttf
Among them, the ttf font used.
In the C: \ Windows \ Fonts path of the Windows system