Reputation: 3
I have been trying this code to create multiple scatterplots with a single point but it plots three points in one figure. How to create nine figures with only one data point?
import matplotlib.pyplot as plt
h=[[0,2,5,7],[0,4,15,11],[0,8,25,13]]
g=it.combinations([1,3,2],2)
k=[]
for i in list(g):
k.append(list(i))
print(k)
for j in range(3):
plt.subplot(3,3, j+1)
for n in k:
plt.scatter(h[j][n[0]],h[j][n[1]])
j=j+1
This is the output. But how to make it nine figures
Upvotes: 0
Views: 138
Reputation: 331
import itertools as it
import matplotlib.pyplot as plt
h=[[0,2,5,7],[0,4,15,11],[0,8,25,13]]
g=it.combinations([1,3,2],2)
k=[]
for i in list(g):
k.append(list(i))
print(k)
fig,axs=plt.subplots(3,3)
for j in range(3):
for i,n in enumerate(k):
axs[j][i].scatter(h[j][n[0]],h[j][n[1]])
j=j+1
plt.show()
Upvotes: 1