此问题已在此处有答案:
How do I fix 'x and y must be the same size' error?(1个答案)
ValueError: x and y must be the same size(3个答案)
"ValueError: x and y must be the same size" with scatter plot(1个答案)
ValueError: x and y must be the same size when ploting predicted values(1个答案)
9天前关闭
当我运行这个代码块时:
plt.plot(tag_counts[0:100], c='b')
plt.scatter(x=list(range(0,100,5)), y=tag_counts[0:100:5], c='orange', label="quantiles with 0.05 intervals")
# quantiles with 0.25 difference
plt.scatter(x=list(range(0,100,25)), y=tag_counts[0:100:25], c='m', label = "quantiles with 0.25 intervals")
for x,y in zip(list(range(0,100,25)), tag_counts[0:100:25]):
plt.annotate(s="({} , {})".format(x,y), xy=(x,y), xytext=(x-0.05, y+500))
plt.legend()
plt.show()
print(len(tag_counts[0:100:5]), tag_counts[0:100:5])
我得到这个错误:
1420 @functools.wraps(func)
1421 def inner(ax, *args, data=None, **kwargs):
...
4522 if s is None:
4523 s = (20 if mpl.rcParams['_internal.classic_mode'] else
4524 mpl.rcParams['lines.markersize'] ** 2.0)
ValueError: x and y must be the same size
我知道我需要调整x和y的大小,但我不知道如何在代码中显示它,以及我应该做什么样的改变。你能帮帮我吗?如果你需要更多的细节,你可以在这里检查我的代码:https://www.kaggle.com/code/ajaysh/stackoverflow-tag-prediction/notebook
1条答案
按热度按时间piv4azn71#
以下是我如何修复我得到的错误: