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軸')plt.show()在使用

在使用matplotlib及seaborn時,中文無法正常顯示,顯示結果為一個方框,解決方法:

  • Matplotlib
import numpy as npimport matplotlib.pyplot as pltplt.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/zh-Hant/articles/detail/Matplotlib%20and%20Seaborn%20Chinese%20display%20problem%20analysis.html

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

相關推薦