plot not showing up

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Fri Aug 10 13:51:03 EDT 2018


try adding

plt.show()

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
Mauritius

On Fri, 10 Aug 2018, 21:50 Sharan Basappa, <sharan.basappa at gmail.com> wrote:

> What is wrong with the following code. Python does not show the plot.
>
> from sklearn.datasets import load_digits
> from sklearn.cluster import KMeans
> import matplotlib.pyplot as plt
>
> digits = load_digits()
> digits.data.shape
>
> kmeans = KMeans(n_clusters=10,random_state=0)
> clusters = kmeans.fit_predict(digits.data)
> kmeans.cluster_centers_.shape
>
> fig, ax = plt.subplots(2,5,figsize=(8,3))
> centers = kmeans.cluster_centers_.reshape(10,8,8)
> for axi, center in zip(ax.flat, centers):
>     axi.set(xticks=[], yticks=[])
>     axi.imshow(center, interpolation='nearest', cmap=plt.cm.binary)
> --
> https://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list