鸢尾花分类散点图

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()
posted @ 2021-08-23 11:27  missking  阅读(333)  评论(0编辑  收藏  举报