在使用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
评论列表(196条)
测试