Python 如何在一个散点图上在自己的列上绘制多个数据集

Python 如何在一个散点图上在自己的列上绘制多个数据集,python,matplotlib,scatter-plot,Python,Matplotlib,Scatter Plot,我有5个数组,每个数组包含30个值。我想在一个散点图中,将每个数组绘制在它自己的列上。 所以我想最后得到一个散点图,有5列,每列有30个数据点。我不希望数组重叠,这是我现在在代码中遇到的问题 plt.scatter(y,Coh1mean40,label='1', c='r') plt.scatter(y, Coh75mean40,label='75', c='b') plt.scatter(y,Coh05mean40,label='50', c='y') plt.scatter(y,Coh25m

我有5个数组,每个数组包含30个值。我想在一个散点图中,将每个数组绘制在它自己的列上。 所以我想最后得到一个散点图,有5列,每列有30个数据点。我不希望数组重叠,这是我现在在代码中遇到的问题

plt.scatter(y,Coh1mean40,label='1', c='r')
plt.scatter(y, Coh75mean40,label='75', c='b')
plt.scatter(y,Coh05mean40,label='50', c='y')
plt.scatter(y,Coh25mean40,label='25', c='g')
plt.scatter(y,Coh00mean40,label='0')
plt.legend()
plt.show()
这段代码给了我一个散点图,上面有所有的数据点,但它们都重叠,没有明显的列

y只是一个包含30个数字的列表,因为plt.scatter函数需要两个参数。
Coh1mean40、Coh75mean40等都是数组,每个数组中包含[0.435、0.56、0.645…]30个值

您需要为每个数组的每个调用指定一个唯一的
y
,因为每个数组将位于不同的“列”中。最好将其称为
x
,因为您使用第一个参数定义每个点的x值

x = np.ones(30)

plt.scatter(0 * x,Coh1mean40,label='1', c='r')
plt.scatter(1 * x, Coh75mean40,label='75', c='b')
plt.scatter(2 * x,Coh05mean40,label='50', c='y')
plt.scatter(3 * x,Coh25mean40,label='25', c='g')
plt.scatter(4 * x,Coh00mean40,label='0')
plt.legend()
plt.show()

但是,您可能希望转而研究Seaborn,特别是

没问题!如果你觉得它有用,请考虑答案。