以鸢尾花数据集为例
#创造环境
import pandas as pd
from pandas.plotting import parallel_coordinates
import numpy as np
import matplotlib.pyplot as plt
#引入数据,此时为dataframe
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
iris = pd.read_csv(url, names=names)
#从dataframe中提取数据,并将其作为散点图
d1=iris['sepal-length']#直接后面中括号,里面是列标签名字即可
d2=iris['sepal-width']
plt.scatter(d1[:50], d2[:50], color='red',
marker='o', label='setosa') #前50个样本
plt.scatter(d1[50:100], d2[50:100],
color='blue', marker='x', label='versicolor') #中间50个
plt.scatter(d1[100:], d2[100:],
color='green', marker='+', label='Virginica') #后50个样本
plt.legend(loc=2) #左上角标签
plt.show()