【发布时间】:2021-02-25 18:17:49
【问题描述】:
这里是初学者。在我们的遗传课程中,我们被要求使用 Excel 来创建绘图,但我想用 Python 来做。当我尝试绘制散点图时,我得到x=y 行。我认为我必须将我的数据设置为坐标
data = [
[1, 2],
[3, 2],
[4, 7],
[2, 4],
[...],
]
x, y = zip(*data)
plt.scatter(x, y)
plt.show()
如其他地方所示。但我正在努力做到这一点。
我暂时这样做了,但我不知道如何将这两个列表用作[x, y] 然后进行绘图。
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()
但我想要坐标簇 [x,y],它应该是这样的:
【问题讨论】:
-
尝试将
decimal=','添加到read_csv调用中。
标签: python matplotlib scatter-plot