英文:
x and y are different sizes
问题
distrobution.plot(x=["观察值", "模型值"], y=["金额(毫米)"], kind="散点图")
英文:
distrobution.plot(x = ["Observed", "Modelled"], y = ["Amount (mm)"], kind = "scatter")
for the following dataframe:
I am getting the error:
x and y must be the same size
How are they not the same size?
答案1
得分: 1
你必须分别绘制每个系列:
fig, ax = plt.subplots(figsize=(8, 4))
df.plot.scatter(x='观察值', y="降水量(毫米)", color='blue', ax=ax, legend=True)
df.plot.scatter(x='模拟值', y="降水量(毫米)", color='green', ax=ax, legend=True)
ax.set_ylabel('降水量(毫米)')
ax.set_xlabel('计数')
ax.set_title('每日降水分布')
ax.legend(['观察值', '模拟值'], loc='upper right')
plt.show()
英文:
You have to plot each series separately:
fig, ax = plt.subplots(figsize=(8, 4))
df.plot.scatter(x='Observed', y="Amount (mm)", color='blue', ax=ax, legend=True)
df.plot.scatter(x='Modelled', y="Amount (mm)", color='green', ax=ax, legend=True)
ax.set_ylabel('Rainfall (mm)')
ax.set_xlabel('Count')
ax.set_title('Daily Rainfall Distribution')
ax.legend(['Observed', 'Modelled'], loc='upper right')
plt.show()
答案2
得分: 0
在你的示例中,x
和 y
是具有不同长度的字符串列表。我猜这就是错误消息想告诉你的。
英文:
In your example, x
and y
are lists of strings with different lengths. I assume that's what the error message is telling you.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论