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

How to set up Chinese interface in python

coldplay.xixi
Release: 2020-10-26 15:32:58
Original
40947 people have browsed it

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/
Copy after login

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)
...
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template