python - 循环内带有空圆圈的散点图
问题描述
我正在寻找一种简单而优雅的方法来制作具有多个数组的散点图,使用空圆圈作为标记颜色应该自动选择。例如,我可以很容易地制作一个带有实心圆的图:
a = {'1': np.random.rand(10), '2': np.random.rand(10), '3': np.random.rand(10)}
fig,ax = plt.subplots()
for y in ['2', '3']:
ax.scatter(a[y], a['1'], label=y)
如果我想使用 kwargs facecolor="none"
,标记就会消失。不知何故我需要自动分配颜色edgecolor
解决方案
C0
通过遵循默认调色板的、C1
等手动分配边缘颜色:
a = {'1': np.random.rand(10), '2': np.random.rand(10), '3': np.random.rand(10)}
fig,ax = plt.subplots()
for i, y in enumerate(['2', '3']):
ax.scatter(a[y], a['1'], label=y, facecolor='none', edgecolor=f'C{i}')
推荐阅读
- c - 如何使用 cairo 绘制具有左上角和右下角切角的矩形?
- c# - 如何在 Windows 10 中创建可以处理 URL:callto 和 URL:tel 协议的 WPF 应用程序?
- android - MapsActivity Android 不在一个项目中工作,但从头开始的项目工作
- recursion - 2 次方的递归硬币找零(分区)
- perl - Perl 脚本提示输入密码,但不接受来自 ksh 的输入
- datetime - RobotFramework:将月份从日期转换为数字格式
- javascript - Typescript 导入与 JavaScript 导入
- android - 如何使用 ZXing 和 android CameraX 来解码 Barcode 和 QR Codes
- sql-server - 使用 VBA (Excel) 连接到 SQL Server 2016
- python - 如何使用groupby在python pandas中按条件递增