[英]how to do the scatter plot for the lists or 2d array or matrix python?
X=[[0,3,4,0,1,1],
[0,0,0,5,1,1],
[6,7,0,8,1,1],
[3,6,1,5,6,1]]
Y=[12,15,11,10]
I have the lists how to do the scatter plot to visualize the X , Y to check that relationship?? 我有列表如何做散点图以可视化X,Y来检查这种关系?
Your X being in the wrong orientation, I'm using a numpy array to easily transpose it. 您的X方向错误,我正在使用numpy数组轻松对其进行转置。 Then it's just a matter of plotting it on the same axis, changing the colors so you can see what's what. 然后,只需将其绘制在同一根轴上,然后更改颜色即可看到什么。
import numpy as np
import matplotlib.pyplot as plt
x_arr = np.array(X)
y = np.array(Y)
fig, ax = plt.subplots()
colors=list('bgrcmykw')
for i, x in enumerate(x_arr.T):
ax.scatter(x,y, c=colors[i])
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.