在matplotlib中设置默认散点图标记

2024-09-26 22:54:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一种方法来设置plt.scatter()的默认标记-我尝试在matplotlibrc文件中设置这行:

lines.marker    : +

但这似乎不会改变默认标记,即圆。在

http://matplotlib.org/users/customizing.html似乎也没有其他明显的参数要设置;有人知道是否可以为散点图设置默认标记?在


Tags: 文件方法标记orghttp参数matplotlibhtml
1条回答
网友
1楼 · 发布于 2024-09-26 22:54:43

您可以通过直接更改site-packages/matplotlib/pyplot.py中的代码来完成此操作:

# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost
@_autogen_docstring(Axes.scatter)
def scatter(x, y, s=20, c=None, marker='+', cmap=None, norm=None, vmin=None,
            vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
            hold=None, data=None, **kwargs):
    ax = gca()
    # allow callers to override the hold state by passing hold=True|False
    washold = ax.ishold()

注意评论中的警告,因为我不知道什么时候样板.py正在调用。(您只需要尝试一下并查看)但是,在实际更改源之前,请考虑将plt.scatter与您自己的调用重叠:

^{pr2}$

相关问题 更多 >

    热门问题