回答问题

在 Python 中,使用 Matplotlib,如何绘制带有 empty 圆圈的散点图?目标是在scatter()已经绘制的_一些_ 彩色圆盘周围绘制空圆圈,以便突出显示它们,理想情况下无需重新绘制彩色圆圈。

我试过facecolors=None,无济于事。

Answers

从文档分散:

Optional kwargs control the Collection properties; in particular:

    edgecolors:
        The string ‘none’ to plot faces with no outlines
    facecolors:
        The string ‘none’ to plot unfilled outlines

尝试以下操作:

import matplotlib.pyplot as plt 
import numpy as np 

x = np.random.randn(60) 
y = np.random.randn(60)

plt.scatter(x, y, s=80, facecolors='none', edgecolors='r')
plt.show()

示例图像

注: 对于其他类型的地块,请参阅这篇文章关于markeredgecolormarkerfacecolor的使用。

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐