简体   繁体   English

Matplotlib散射标记大小

[英]Matplotlib scatter marker size

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 我正在尝试使用matplotlib绘制3D散射问题是我无法更改标记的大小我有这个

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? 还是有另一种方法来改变大小?

This function takes in two args before the keyword args: 此函数在关键字args之前接受两个args:

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

And you are passing in three, so you are specifying s twice (once implicitly and once explicitly). 和你逝去的三个,所以你指定s两次(一次暗示和明确的一次)。

Actually, I think you are trying to use the 2D scatter plot function instead of a 3D one. 实际上,我认为您正在尝试使用2D散点图函数而不是3D散点图函数。 You probably want to do this instead: 您可能想要这样做:

from mpl_toolkits.mplot3d import Axes3D
Axes3D.scatter( ... )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM