[英]how to create coordinate [x,y] with two list (for a scatter plot, matplotlib)
Beginner here.初学者在这里。 In our g.netic course, we are asked to use Excel to create a plot, but I want to do it with Python. When I try to do a scatter plot, I get the line
x=y
.在我们的 g.netic 课程中,我们被要求使用 Excel 创建一个 plot,但我想用 Python 来创建它。当我尝试做一个散点图 plot 时,我得到了
x=y
行。 I think that I have to set my data as coordinate like我认为我必须将我的数据设置为坐标
data = [
[1, 2],
[3, 2],
[4, 7],
[2, 4],
[...],
]
x, y = zip(*data)
plt.scatter(x, y)
plt.show()
as shown elsewhere.如其他地方所示。 But I am struggling to do just that.
但我正在努力做到这一点。
I did this for now, but I don't know how to use those two lists as [x, y]
and then plot.我现在这样做了,但我不知道如何将这两个列表用作
[x, y]
,然后是 plot。
import pandas as pd
import matplotlib.pyplot as plt
def read_csvfile(file):
df = pd.read_csv(file, sep=';', header=0)
return df
cal = read_csvfile('Genotypage_BCM2531_snp49.csv')
x = cal['Signal_FAM']
y = cal['Signal_VIC']
plt.scatter(x, y)
plt.show()
But I want to have clusters of coordinates [x,y], and it should look like this:但我想要坐标簇 [x,y],它应该如下所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.