中文字体设置
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.linspace(-5, 5)
y = np.sin(x)
plt.title('y等于sinx')
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x2088ed04ac0>]
D:\Anaconda3\Install\lib\site-packages\IPython\core\pylabtools.py:151: UserWarning: Glyph 31561 (\N{CJK UNIFIED IDEOGRAPH-7B49}) missing from current font.
fig.canvas.print_figure(bytes_io, **kw)
D:\Anaconda3\Install\lib\site-packages\IPython\core\pylabtools.py:151: UserWarning: Glyph 20110 (\N{CJK UNIFIED IDEOGRAPH-4E8E}) missing from current font.
fig.canvas.print_figure(bytes_io, **kw)

matplotlib 中默认是无法处理中文字体的 应该如何处理?
解决办法:①设置字体样式及正常显示 ②但是中文里负号不能显示 在设置符号的显示
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.title('y等于sinx')
plt.plot(x, y)

中文字体的一些样式
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-a08a0Tot-1648530115557)(attachment:image.png)]](https://img-blog.csdnimg.cn/61b19be63a404b889a02a405b47dacca.png)
show() 方法
如果想在jupyter notebook中 显示的图片也有互动效果 可以按照下方设置
%matplotlib notebook
plt.plot(x, y)
|