Python Forum

Full Version: how to nest loop for 4*4 scatter plot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am new and trying to write a 4 by 4 scatter matrix using for loop and subplot functions. The data is iris. I have run this code but nothing is getting returned. Please review it and advise,what went wrong, thanks.

from sklearn import datasets
import matplotlib.pyplot as plt
%matplotlib inline
iris = datasets.load_iris()

X=iris.data
Y=iris.target

t= 1
for i in range (0,4):
    for j in range (0,4):
        ax = fig.add_subplot(4,4,t)
        ax.scatter(X[:, i], X[:, j], c=Y, cmap=plt.cm.Paired)
        t=t+1
        plt.show()