如何在一个散点图上的自己的列上绘制多个数据集
How to plot multiple datasets on their own column on one 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,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
,因为每个数组的每个调用都会落入不同的 "column"。最好将它称为 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,具体来说 stripplot
我有 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
,因为每个数组的每个调用都会落入不同的 "column"。最好将它称为 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,具体来说 stripplot