simhei是什么字体:Matplotlib及Seaborn中文显示问题解析-字体教程免费ppt模版下载-道格办公

Matplotlib及Seaborn中文显示问题解析

rt matplotlib.pyplot as plt # 设置中文显示 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False # 以下为示例代码 x = np.linspace(0, 2 * np.pi, 100) y = np.sin(x) plt.plot(x, y) plt.title('正弦曲线') plt.xlabel('X轴') plt.ylabel('Y轴') p

在使用matplotlib及seaborn时,中文无法正常显示,显示结果为一个方框,解决方法:

  • Matplotlib
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['SimHei'] # 解决中文显示问题-设置字体为黑体
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题

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

文章为用户上传,仅供非商业浏览。发布者:Lomu,转转请注明出处: https://www.daogebangong.com/articles/detail/Matplotlib%20and%20Seaborn%20Chinese%20display%20problem%20analysis.html

(810)
打赏 支付宝扫一扫 支付宝扫一扫
single-end

相关推荐