I'm new to matplotlib and I'm learning how to work with it. With my code I'm trying to plot multiple scatterplots, but there are always unwanted lines that I can't get rid off.
See image attached to this post.
Here is my Python code:
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn import cluster
iris = datasets.load_iris()
for i in range(1,7):
kmeans = cluster.KMeans(n_clusters=i).fit(iris.data)
Centers = kmeans.cluster_centers_
plot_nr = 230+i
plt.subplot(plot_nr)
text = str(i) + ' Cluster'
plt.scatter(iris.data[:,0], iris.data[:,1], c=kmeans.labels_)
plt.scatter(Centers[:,0], Centers[:,1], c='r', s=150, marker='*')
plt.title(text)
plt.savefig('Iris.png')
plt.show()
I'm thankful for every suggestion!
Thanks, Thomas
Plot with unwanted lines

import matplotlib.pyplot as plt; from sklearn import datasets; from sklearn import cluster; iris = datasets.load_iris()to the top of your code and it should be runnable for all. thanks.