本文介绍了Matplotlib scatter():大小,标记形状的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为 matplotlib plt.scatter() 设置 default 标记大小 (s) 参数(或同样设置标记的形状)?

Is there a way to set default marker size (s) parameter for matplotlib plt.scatter() (or likewise to set the shape of the marker)?

mpl.rcParams.keys()具有折线图的设置,例如

mpl.rcParams.keys() has settings for the line plots, e.g.

import matplotlib as mpl
mpl.rcParams['lines.marker']='D'

...但它们似乎与 plt.scatter() 无关.

... but they do not seem to relate to plt.scatter().

谢谢.

说明:

我想使用像 mpl.rcParams() 这样的配置机制,或者其他一些合理的文明方法.本地修改库代码不行.

I'd like to use a configuration mechanism like mpl.rcParams(), or some other reasonably civilized method. Locally modifying library code is not it.

另一方面,如果当前无法完成,并且有人向Matplotlib提交了补丁,那就太好了.

On the other hand, if it cannot currently be done and somebody submits a patch to Matplotlib, that would be awesome.

推荐答案

当然有,所有内容都在 pyplot.py

Of course there is, it's all in the pyplot.py

他们的代码片段:

def scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None,
            vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
            hold=None, data=None, **kwargs):

大小设置为20 s = 20 ,标记形状为圆形 marker ='o',与文档一致.

The size is set to 20 s=20 and the marker shape is a circle marker='o' which agrees with their documentation

这篇关于Matplotlib scatter():大小,标记形状的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 11:37