图表不能插入中文
大家有没有遇到中文乱码问题,怎么解决啊?#coding:utf-8不管用啊
#coding=utf-8
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
y=df.loc[0:100, 4].values
y=np.where(y=='Iris-setosa',1,-1)
X=df.iloc[0:100,[0,2]].values
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['font.serif'] = ['SimHei']
plt.scatter(X[:50,0],X[:50,1],color='red',marker='o',label='setosa')
plt.scatter(X[50:100,0],X[50:100,1],color='blue',marker='x',label='versicolor')
plt.xlabel('长度')
plt.ylabel('宽度')
plt.legend(loc='upper left')
plt.show()