[英]scatter plot with empty circle within loop
I am looking for a simple and elegant way to make a scatter plot with multiple arrays, using empty circle as marker The colours should be chosen automatically.我正在寻找一种简单而优雅的方法来制作具有多个 arrays 的散点 plot,使用空圆圈作为标记颜色应该自动选择。 For example, I can make a plot with filled circle very easily:
例如,我可以很容易地制作一个带有实心圆的 plot:
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)
IF I want to use the kwargs facecolor="none"
, the markers just disappear.如果我想使用 kwargs
facecolor="none"
,标记就会消失。 Somehow I need to automatically assign colors to edgecolor
不知何故,我需要自动将 colors 分配给
edgecolor
Assign the edge color manually via C0
, C1
, etc., which follow the default palette:通过遵循默认调色板的
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}')
You can also use string o
as a marker
:您还可以使用字符串
o
作为marker
:
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, marker='$o$')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.