鸢尾花分类散点图

from sklearn.datasets import load_iris
import matplotlib
import matplotlib.pyplot as plt


iris= load_iris()

matplotlib.rcParams[‘font.sans-serif‘] = [‘SimHei‘]
matplotlib.rcParams[‘axes.unicode_minus‘] = False

x_index =0
y_index =1
colors =[‘red‘, ‘green‘, ‘blue‘]

for label, color in zip(range(len(iris.target_names)), colors):
    plt.scatter(iris.data[iris.target==label, x_index],
        iris.data[iris.target==label, y_index],
        # label = iris.target_names[label],
         c = color,alpha = 3/10)
       # 透明度设置

plt.xlabel(‘萼片长度‘)
plt.ylabel(‘萼片宽度‘)
plt.legend
plt.show()

鸢尾花分类散点图

上一篇:3D点云降维处理


下一篇:scanf()函数的原理