text_plain_output_1.png image_output_1.png
from sklearn.datasets import load_iris

import matplotlib.pyplot as plt

from sklearn.datasets import load_iris
data = load_iris()
n_samples, n_features = data.data.shape

x_index = 1
y_index = 2
formatter = plt.FuncFormatter(lambda i, *args: data.target_names[int(i)])
plt.scatter(data.data[:, x_index], data.data[:, y_index], c=data.target, cmap=plt.cm.get_cmap('RdYlBu', 3))
plt.colorbar(ticks=[0, 1, 2], format=formatter)
plt.clim(-0.5, 2.5)
plt.xlabel(data.feature_names[x_index])
plt.ylabel(data.feature_names[y_index])