x 和 y 尺寸不同

huangapple go评论97阅读模式
英文:

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:

x 和 y 尺寸不同

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()

x 和 y 尺寸不同

英文:

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()

x 和 y 尺寸不同

答案2

得分: 0

在你的示例中,xy 是具有不同长度的字符串列表。我猜这就是错误消息想告诉你的。

英文:

In your example, x and y are lists of strings with different lengths. I assume that's what the error message is telling you.

huangapple
  • 本文由 发表于 2023年4月17日 04:18:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030125.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定