[英]Matplotlib scatter(): default value for size, marker shape
Is there a way to set default marker size ( s
) parameter for matplotlib plt.scatter()
(or likewise to set the shape of the marker)?有没有办法为 matplotlib
plt.scatter()
设置默认标记大小( s
)参数(或同样设置标记的形状)?
mpl.rcParams.keys()
has settings for the line plots, eg mpl.rcParams.keys()
具有线图的设置,例如
import matplotlib as mpl
mpl.rcParams['lines.marker']='D'
... but they do not seem to relate to plt.scatter()
. ...但它们似乎与
plt.scatter()
。
Thanks.谢谢。
Clarification:澄清:
I'd like to use a configuration mechanism like mpl.rcParams()
, or some other reasonably civilized method.我想使用像
mpl.rcParams()
这样的配置机制,或者其他一些合理的文明方法。 Locally modifying library code is not it.本地修改库代码不行。
On the other hand, if it cannot currently be done and somebody submits a patch to Matplotlib, that would be awesome.另一方面,如果目前无法完成并且有人向 Matplotlib 提交补丁,那将是非常棒的。
Of course there is, it's all in the pyplot.py当然有,都在pyplot.py里
A snippet from their code:他们的代码片段:
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):
The size is set to 20 s=20
and the marker shape is a circle marker='o'
which agrees with their documentation大小设置为 20
s=20
并且标记形状是圆形marker='o'
,与他们的文档一致
In the current release, marker size is defined as:在当前版本中,标记大小定义为:
"The marker size in points**2. Default is rcParams['lines.markersize'] ** 2." “以磅为单位的标记大小**2。默认值为 rcParams['lines.markersize'] ** 2。”
So setting rcParams['lines.markersize'] should change the default marker size for scatterplots too now.因此,现在设置 rcParams['lines.markersize'] 也应该更改散点图的默认标记大小。 See https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html
见https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html
It is not possible in the current release of matplotlib ( http://matplotlib.org/users/customizing.html ).在当前版本的 matplotlib ( http://matplotlib.org/users/customizing.html ) 中是不可能的。
However, there is an option to change the default marker in the master branch on GitHub ( https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/rcsetup.py#L1112 ).但是,有一个选项可以更改 GitHub 上 master 分支中的默认标记( https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/rcsetup.py#L1112 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.