IIUC,你不需要
zip
步骤:
s = (arr1.ravel(), arr2.ravel())
plt.scatter(*s)
plt.show()
或者,你也可以通过策划
arr1
和
arr2
:
plt.scatter(arr1, arr2)
plt.show()
原因是,通过压缩,可以创建许多坐标元组:
>>> list(zip(*s))
[(0.5233576831070681, 0.3622905772322086), (0.6771459051981418, 0.46550530512072197), (0.5836238435117137, 0.9678582465614765), (0.5215640961420361, 0.05930220671158393), (0.0671420867491811, 0.3229294577997751), (0.09453539420217905, 0.5853394743453684), (0.14945382971858256, 0.7100764985571005), (0.6097216935812977, 0.008285702808878748), (0.8008615396938863, 0.8564656781773946), (0.0012100717276920525, 0.03915037044723313), (0.5749921053520953, 0.43147487440006294), (0.5965950855156836, 0.6485170240649151), (0.00223226469849902, 0.3134990067863225), (0.6424325871844799, 0.4041957463865189), (0.06797409254523168, 0.685192515451394), (0.9485129458199039, 0.6873427463294267)]
这是正确的(虽然它们不能打包成2个变量,因为它是16个坐标对),但是您基本上希望通过迭代来绘制它们,这并不理想。或者你
能够
重新压缩它们,但我认为这不是一个有效的方法:
x,y = zip(*zip(*s))
plt.scatter(x,y)
plt.show()