Recently, a least-squares code was written and a picture was drawn with matplotlib, but the problem of Chinese garbled characters was encountered. After a simple search, it was found that someone had summed up a better solution, and the pro-test was feasible. Recommend to everyone.
The precondition of this article is already installed good matplotlib, as to Matplotlib is what, how installs, this article does not introduce.
First find the Microsoft Jas font file under the Windows disk area:
Second, locate the Matplotlab Font Library folder or the System Font Library folder
Matplotlab Font Library folder
System Font Library folder
Copy the font file to either of the two paths.
Then, locate the Matplotlib configuration file
You can modify the file directly, or
Then, modify the configuration file.
Edit the configuration file to findfont.family
, remove the comment, and in the font.sans - serif :Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial,Helvetica, Avant Garde, sans - serif
following Plus Chinese fonts Microsoft YaHei
.
Finally, clear the cache
Made the above changes and found nothing to do with it.
The ~/.cache/matplotlib
next file is deleted and it's OK.
Matplotlib legend Chinese garbled in Ubuntu environment