问题
I'm trying to plot a 3D scatter with matplotlib
The problem is that I can't change the marker's size
I have this
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)
But I get the error
TypeError: scatter() got multiple values for keyword argument 's'
Without that, the plot works fine. Where is the problem? Or is there another way to change the size?
回答1:
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( ... )
来源:https://stackoverflow.com/questions/19451400/matplotlib-scatter-marker-size