1
votes

I have 5 arrays that each contain 30 values. I want to plot each array on its own column in one scatter plot. So I want to end up with one scatter plot with 5 columns, each with 30 data points plotted in each column. I do NOT want the arrays to overlap, which is the issue I am having with my code now.

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()

this code gives me one scatter plot with all the data points but they all overlap, there are no distinct columns.

y is just a list of 30 numbers because the plt.scatter function needs two arguments. The Coh1mean40, Coh75mean40,etc. are all arrays containing [0.435, 0.56, 0.645...] 30 values in each

1

1 Answers

1
votes

You need to specify a unique y for each call for each array will fall in a different "column". It would be better WAY better to call it x instead since you are defining the x value of each point with the first argument.

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()

However, you may want to look into Seaborn instead, specifically stripplot