简体   繁体   English

错误:x 和 y 必须具有相同的第一维。 为什么?

[英]Error: x and y must have same first dimension. Why?

Why do I get the error: "x and y must have same first dimension, but have shapes (15,) and (23,)"?为什么我会收到错误消息:“x 和 y 必须具有相同的第一维,但具有形状 (15,) 和 (23,)”?

index = np.where(A3_Fixed == 0)[0]

for x in index:
    A2.pop(x)
    A3_Fixed.pop(x)
    A4_Fixed.pop(x)
    A5_Fixed.pop(x)
    A6_Fixed.pop(x)
plt.plot(A2, A3_Fixed, color="brown", label="Pasta In P1", marker="o")
plt.plot(A2, A4_Fixed, color="brown", linestyle=":", label="Pasta Out P1", marker="o")
plt.plot(A2, A5_Fixed, color="green", label="Líquido de Lavagem P1", marker="o")
plt.plot(A2, A6_Fixed, color="green", label="Filtrado P1", linestyle=":", marker="o")

If A2 and A3_fixed are lists, you can ensure they are the same size by performing the following and see if your problem persists.如果A2A3_fixed是列表,您可以通过执行以下操作确保它们的大小相同,并查看您的问题是否仍然存在。 If it does, then somehow you did not have the same number of values for your x and y , as pavel mentioned in their comment.如果是这样,那么不知何故,您的xy值的数量不一样,正如 pavel 在他们的评论中提到的那样。

# limit both lists to the size of the smaller one
A2 = [:min(len(A2),len(A3_fixed))]
A3_fixed = [:min(len(A2),len(A3_fixed))]

You can also just check the lengths of each right before attempting to plot by calling print(len(list_name)) .您也可以通过调用print(len(list_name))在尝试 plot 之前检查每个权利的长度。

暂无
暂无

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

相关问题 Val Error,x和y必须具有相同的尺寸。 [我试图做np.array,但没有帮助] - Val Error, x and y must have the same dimension. [I tried to do np.array but it hasn't helped] x和y必须在python中具有相同的第一维错误 - x and y must have same first dimension ERROR in python 输入错误,然后输入值错误:x 和 y 必须具有相同的第一维 - Type error, and then ValueError: x and y must have same first dimension 值错误:x和y必须具有相同的第一维 - Value Error: x and y must have the same first dimension 错误:x 和 y 必须具有相同的第一维 - Error: x and y must have the same first dimension Matplotlib:ValueError:x和y必须具有相同的第一维错误 - Matplotlib: ValueError: x and y must have same first dimension Error x和y必须具有相同的第一尺寸,但形状为(30,)和(1,) - x and y must have same first dimension, but have shapes (30,) and (1,) ValueError:x 和 y 必须具有相同的第一维,但具有形状 (6,) 和 (8,) - ValueError: x and y must have same first dimension, but have shapes (6,) and (8,) 为什么我不断得到“x 和 y 必须具有相同的第一维,但具有形状 (100,) 和 (1, 100)”? - Why do I keep on getting “x and y must have same first dimension, but have shapes (100,) and (1, 100)”? ValueError:x 和 y 必须具有相同的第一维,但具有形状 (1, 2) 和 (2,) - ValueError: x and y must have same first dimension, but have shapes (1, 2) and (2,)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM