我试着在scatter()
中描绘每天的贸易货币
所以我写了一个简单的例子如下:
plt.scatter(train_EDA[(train_EDA['tradeMonth'] == 1)]['tradeDay'],\
train_EDA[(train_EDA['tradeMonth'] == 1)]['tradeMoney'])
绝对正确。
所以我每个月都试着画如下图:
nrows, ncols = 12, 1
fig, ax = plt.subplots(nrows=12, ncols=1, figsize=(8, 96))
for i in range(12):
ax[i].scatter(train_EDA[(train_EDA['tradeMonth'] == i)]['tradeDay'],
train_EDA[(train_EDA['tradeMonth'] == 1)]['tradeMoney'])
绘图都是空白的。
错误信息如下:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last) in
3
4 for i in range(12):
----> 5 ax[i].scatter(train_EDA[(train_EDA['tradeMonth'] == i)]
['tradeDay'], train_EDA[(train_EDA['tradeMonth'] == 1)]['tradeMoney'])~\Anaconda3\lib\site-packages\matplotlib__init__.py in inner(ax, data, *args, **kwargs)
1808 "the Matplotlib list!)" % (label_namer, func.name),
1809
RuntimeWarning, stacklevel=2)
-> 1810 return func(ax, *args, **kwargs)
1811
1812 inner.doc = _add_data_doc(inner.doc,
~\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
4180 y = np.ma.ravel(y)
4181 if x.size != y.size:
-> 4182 raise ValueError("x and y must be the same size")
4183
4184 if s is None:
ValueError: x and y must be the same size
以下是数据帧:
tradeMonth tradeDay tradeMoney
0 12 22 16000.0
1 11 14 14000.0
2 2 10 6000.0
3 4 16 3400.0
4 2 28 8000.0
5 3 24 3000.0
......
......
......
在搜索some relevant questions之后,它的错误主要是由数据的维数引起的。
但不存在这样的问题。
有谁能帮我解决这个问题吗?你知道吗
看起来你不小心把一个
1
放在你想要找零钱的地方了至
相关问题 更多 >
编程相关推荐