1

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

2 Answers 2

2

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}')
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. But how do I access the default palette (f'C{i}')
@VinodKumar those colors work by default. You can control them e.g. with seaborn: seaborn.pydata.org/tutorial/color_palettes.html
Perfect, Thanks a lot!
@VinodKumar you are welcome! If this answer satisfies you, please accept it.
Done that! StackOverflow allows me to accept the answer after a time delay.
1

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

2 Comments

This is smart but only a way around. I have limited flexibility to choose markers in this way.
@VinodKumar Yeah I figured, but just wanted to give you another option =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.