**python模块Matplotlib.pyplot中内置样式‘seaborn‘和导入中文有冲突**

python模块Matplotlib.pyplot中内置样式’seaborn’和导入中文有冲突
代码

import matplotlib.pyplot as plt

plt.rcParams['font.family']='SimHei'   #指定默认字体 SimHei为黑体
plt.rcParams['axes.unicode_minus']=False

plt.style.use('seaborn')
fig,ax = plt.subplots()
ax.scatter(2,4,s=200)

#设置图标标题并给坐标加上标签。
ax.set_title('平方数',fontsize=24)
ax.set_xlabel('值',fontsize=14)
ax.set_ylabel('值的平反',fontsize=14)

#设置刻度标记的大小。
ax.tick_params(axis='both',which='major',labelsize=14)
plt.show()

运行如下在这里插入图片描述
下面不运行’seaborn’的代码

import matplotlib.pyplot as plt

plt.rcParams['font.family']='SimHei'   #指定默认字体 SimHei为黑体
plt.rcParams['axes.unicode_minus']=False

#plt.style.use('seaborn')
fig,ax = plt.subplots()
ax.scatter(2,4,s=200)

#设置图标标题并给坐标加上标签。
ax.set_title('平方数',fontsize=24)
ax.set_xlabel('值',fontsize=14)
ax.set_ylabel('值的平反',fontsize=14)

#设置刻度标记的大小。
ax.tick_params(axis='both',which='major',labelsize=14)
plt.show()在这里插入代码片

运行如下
在这里插入图片描述
具体什么原因没搞懂,麻烦有懂的大佬帮帮忙,谢谢。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值