Home  >  Article  >  Backend Development  >  How to set up Chinese interface in python

How to set up Chinese interface in python

coldplay.xixi
coldplay.xixiOriginal
2020-10-26 10:39:5440885browse

How to set up the Chinese interface in python: first find the folder where the windows10 Chinese fonts are located [C:/Windows/Fonts/]; then add the relevant code in front of the code [import matplotlib.pyplot as plt.... 】.

How to set up Chinese interface in python

How to set the Chinese interface in python:

Find the folder where the Windows 10 Chinese fonts are located

C:/Windows/Fonts/

Add in front of the code:

import matplotlib.pyplot as plt
 
plt.rcParams['font.sans-serif']=['simhei'] # 添加中文字体为黑体
plt.rcParams['axes.unicode_minus'] =False
 
...
#ax[0, 0].set_ylabel(u"哈哈") # 注意前面加上'u'.
#ax[2, 0].set_ylabel(u"嘿嘿")
...
 
#或
 
import matplotlib.pyplot as plt
 
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/simsun.ttf") # 添加中文字体为黑体
 
...
ax[0, 0].set_ylabel(u"哈哈", fontproperties=my_font)
ax[2, 0].set_ylabel(u"嘿嘿", fontproperties=my_font)
...

Related free learning recommendations: python video tutorial

The above is the detailed content of How to set up Chinese interface in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn