Matplotlib分散标记大小 [英] Matplotlib scatter marker size

查看:100
本文介绍了Matplotlib分散标记大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)

但我收到错误

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?

推荐答案

此函数在关键字args之前引入两个args:

This function takes in two args before the keyword args:

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

并且您传入了三个,因此您指定了 s 两次(一次隐式,一次显式).

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

实际上,我认为您正在尝试使用 2D 散点图函数而不是 3D 散点图函数.您可能想要这样做:

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

这篇关于Matplotlib分散标记大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆