matplotlib - 绘制多条线时出现奇怪的 y 轴

App*_*pyx 1 python plot matplotlib data-science

为什么这段代码会产生如此奇怪的输出?

我希望图重叠,以便我可以看到重叠的数据点。

这些情节似乎是相互堆叠的。

def read_csv(name):
    file = open(folder+name,newline='')
    reader = csv.reader(file,delimiter=";")
    data = []
    for row in reader:
        data.append(np.array(row[5:]))
    file.close()
    return data


def setup_plotting():
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.xaxis.set_major_locator(plt.MaxNLocator(10))
    ax.yaxis.set_major_locator(plt.MaxNLocator(10))
    return ax


acc_x = read_csv("acc_x.csv")

ax=setup_plotting()

for entry in acc_x:
    ax.plot(entry)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请帮我 :)

ago*_*old 5

问题是csv.reader返回文本,因此绘图不会对值进行排序。int您应该使用或转换值float

for row in reader:
        data.append(np.array([int(x) for x in row[5:]]))
Run Code Online (Sandbox Code Playgroud)