使用此代码绘制 iris 数据集给了我一个额外的空图:
import pandas as pd
from matplotlib import pyplot as plt
d = {'Species': ['setosa', 'versicolor','virginica'], 'Sepal length': [1, 2, 3], 'Sepal width': [2, 4, 6]}
df = pd.DataFrame(data=d)
unv = df['Species'].unique()
colorv = ['r','b','g']
markerv = ['v', 'o', '>']
#Getting an extra empty plot for no reason
fig, ax=plt.subplots(1,2)
for i in range(len(unv)):
df[df['Species'] == unv[i]].plot(x="Sepal length", y="Sepal width", kind="scatter",ax=ax[0],label=unv[i],color=colorv[i], marker = markerv[i])
plt.show()
