Home > Article > Backend Development > What should I do if the Chinese legend in the Ubuntu environment is garbled?
Recently I wrote a code for the least squares method and used matplotlib to draw a picture, but I encountered a problem with Chinese garbled characters. After a simple search, I found that someone had summarized a better solution and it was feasible for personal testing. Recommended to everyone.
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 find the font file of Microsoft Yahei under the Windows partition: Secondly, find the matplotlab font library folder or the system font library folder matplotlab font library folder System font library folder
You can copy the font file to either of these two paths. Then, find the matplotlib configuration file You can modify the file directly, or Then, modify the configuration file.
Edit the configuration file, find font.family<span style="color: #30ea30; font-size: 14px"></span>
, remove the comment, and add the following font.sans - serif :Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial,Helvetica, Avant Garde, sans - serif<span style="color: #30ea30; font-size: 14px"></span>
Add Chinese fontMicrosoft YaHei<span style="color: #30ea30; font-size: 14px"> </span>
.
I made the above changes and found that they were of no use.
Go to ~/.cache/matplotlib<span style="color: #30ea30; font-size: 14px"></span>
and delete the file, then it will be ok.
The above is the detailed content of What should I do if the Chinese legend in the Ubuntu environment is garbled?. For more information, please follow other related articles on the PHP Chinese website!