What is the font of simhei:Matplotlib and Seaborn Chinese display problem analysis-Font Tutorial免费ppt模版下载-道格办公

Matplotlib and Seaborn Chinese display problem analysis

rt matplotlib.pyplot as plt# Set Chinese display plt.rcParams['font.sans-serif'] = ['SimHei']plt.rcParams['axes.unicode_minus'] = False# The following is the sample code x = np.linspace (0, 2 * np.pi, 100)y = np.sin(x)plt.plot(x, y)plt.title('sinusoidal c

When using matplotlib and seaborn, Chinese cannot be displayed normally, and the display result is a box. The solution:

  • Matplotlib
import numpy as npimport matplotlib.pyplot as pltplt.rcParams['font.sans-serif'] = ['SimHei'] # Solve the Chinese display problem- Set the font to bold plt.rcParams['axes.unicode_minus'] = False # Solve the problem that the negative sign '-' is displayed as a square in the saved image x = np.arange(-2*np.pi, 2*np.pi, 0.01)y1 = np.sin(x)y2 = np.cos(x)plt.figure(figsize=(10, 7))plt.plot(x, y1, label='$sinx

Articles are uploaded by users and are for non-commercial browsing only. Posted by: Lomu, please indicate the source: https://www.daogebangong.com/en/articles/detail/Matplotlib%20and%20Seaborn%20Chinese%20display%20problem%20analysis.html

Like (810)
Reward 支付宝扫一扫 支付宝扫一扫
single-end

Related Suggestion