Chinese garbled code of matplotlib legend in Ubuntu environment
The prerequisite for this article is that matplotlib has been installed. As for what matplotlib is and how to install it, this article will not introduce it.
First of all, find the font file of Microsoft Yahei under the Windows area:
Second, find the matplotlab font folder or the system font folder
Matplotlab font library folder
System font library folder
You can copy the font file to either of these two paths.
Then, locate the matplotlib configuration file
You can modify the file directly, or
Then, modify the configuration file.
Edit the configuration file, find font.family, remove the comments, and add the Chinese font Microsoft YaHei in the following font.sans-serif: Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial,Helvetica, Avant Garde, sans-serif.
Finally, clear the cache
After making the above changes, I found that it was of no use.
Delete the file under ~ / .cache / matplotlib and ok it.