将数据从矩阵附加到另一个

Attaching data from matrix to another

我的数据有问题。 一些信息给你: 我有两条数据通道 Bx - 红色一条(运河 1)和 By - 蓝色一条(运河 3),它们都包含 266336 条记录。两次测量均在 300 秒内完成。作为我的情节的结果,我得到了 yaxis,它给了我正确的单位,它是 picoTesla,但是 xaxis 给了我样本数量而不是时间。看:

plt.plot(Bx, label='Canal 1', color='r', linewidth=0.1, linestyle="-")
plt.plot(By, label='Canal 3', color='b', linewidth=0.1, linestyle="-")

关于我的代码,我设法创建了定义时间的矩阵:

dt = float(300)/266336
Fs = 1/dt
t = [0,300,dt*1e3]

我的数据矩阵如下所示:

a = np.amin(data.data)
Bx = data.data[0,]
By = data.data[1,]

我知道从那 266336 条记录中,每秒发生 887,78409 次。但如何做到这一点?怎么写给python,让他知道,每一秒都被887,78409个样本占用。

更新! 使用此代码:

N = len(Bx)
time = np.linspace(0, 300, N)
plt.plot(time, Bx, ...)

我明白了:

看来您需要定义时间的是:np.linspace(0,300,266336)

这将 [0, 300] 间隔分成 266336 等于 'steps'。

N = len(Bx)
time = np.linspace(0, 300, N)
plt.plot(time, Bx, ...)

[mcve]:

import numpy as np
import matplotlib.pyplot as plt 

Bx = np.random.rand(266336)

N = len(Bx)
time = np.linspace(0, 300, N) # or 300000

plt.figure(1).clf()
plt.plot(time, Bx)

如果这个(单独)不起作用,那么我不知道为什么,因为它对我有用。如果它确实有效,但您的脚本没有找到您在脚本中执行的其他操作,这些操作搞砸了您的图形显示...