[英]Type error, and then ValueError: x and y must have same first dimension
[英]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.