繁体   English   中英

错误:x 和 y 必须具有相同的第一维

[英]Error: x and y must have the same first dimension

错误:raise ValueError(f"x and y must have the same first dimension, but " ValueError: x and y must have the same first dimension, but have shapes (1,) and (606976,)

当我在 python 中运行 plot 代码行时出现此错误:(此行的所有信息如下)

    plot_bursts((self.time_array), (self.data), (self.bursting), labels=['C4', 'Detected Burst'])

for i in range(len(self.data)):
            i += 1
            t = i/(2034.50521)
            self.time_array.append(t)


self.bursting = detect_bursts_dual_threshold(self.data, self.fs, 
self.amp_dual_thresh, self.f_range)




data_set = list(C4.items())
    C4 = np.array(data_set)
    C4 = C4[0][1]
    C4 = C4.flatten()
    np.array(C4)
    self.data = C4

不知道怎么解决,请帮忙谢谢!

您的问题不清楚,但这表明您在将数据准备到 plot 时出错。

我假设您在引擎盖下使用matplotlib 例如,当您将不同大小的向量传递给plot时,就会出现此消息。

import matplotlib.pyplot as plt
plt.plot([1], [1,2])

Plot 将尝试将 x 中的每个元素与 y 中的一个元素进行匹配,并且它将失败,因为两个输入中的元素数量不同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM