9

我正在尝试绘制一个 3D 散点图matplotlib 问题是我无法更改标记的大小我有这个

scat = plt.scatter([boid_.pos[0] for boid_ in flock],
                   [boid_.pos[1] for boid_ in flock],
                   [boid_.pos[2] for boid_ in flock], 
                   marker='o', s=5)

但我得到了错误

TypeError: scatter() got multiple values for keyword argument 's'

没有它,情节很好。问题出在哪里?还是有其他方法可以改变大小?

4

1 回答 1

20

This function takes in two args before the keyword args:

scatter(x, y, s=20, ...)

And you are passing in three, so you are specifying s twice (once implicitly and once explicitly).

Actually, I think you are trying to use the 2D scatter plot function instead of a 3D one. You probably want to do this instead:

from mpl_toolkits.mplot3d import Axes3D
Axes3D.scatter( ... )
于 2013-10-18T13:54:52.183 回答