如何在 python 中创建多个包含单个数据点的散点图?
How to create multiple scatterplots with a single data point in them in python?
我一直在尝试使用此代码创建具有单个点的多个散点图,但它在一个图中绘制了三个点。如何用一个数据点创建九个图形?
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
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()
我一直在尝试使用此代码创建具有单个点的多个散点图,但它在一个图中绘制了三个点。如何用一个数据点创建九个图形?
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
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()