Vinod Kumar
Vinod Kumar

Reputation: 1622

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. For example, I can make a plot with filled circle very easily:

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. Somehow I need to automatically assign colors to edgecolor

Upvotes: 1

Views: 249

Answers (2)

ywbaek
ywbaek

Reputation: 3031

You can also use string o as a 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$')

Upvotes: 1

BlackBear
BlackBear

Reputation: 22989

Assign the edge color manually via C0, C1, etc., which follow the default palette:

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}')

Upvotes: 2

Related Questions