0

I would like to add to the plot below open circles surrounding each data point and set the diameter proportional to the values of a 3rd variable. Currently, this is what I tried but the circles are filled and cover the data points. Using "facecolors='none'" did not help.

z = df.z # this is the 3rd variable 
s = [10*2**n for n in range(len(z))]

ax1 = sns.scatterplot(x='LEF', y='NPQ', hue="Regime", markers=["o", 
"^"], s=s, facecolors='none', data=df, ax=ax1)

This is an example of what I mean with circles of different diameters, but now the circles cover the individual data points

JohanC
  • 71,591
  • 8
  • 33
  • 66
  • 2
    Welcome to [Stack Overflow.](https://stackoverflow.com/ "Stack Overflow") Please be aware this is not a code-writing or tutoring service. We can help solve specific, technical problems, not open-ended requests for code or advice. Please edit your question to show what you have tried so far, and what specific problem you need help with. See the [How To Ask a Good Question](https://stackoverflow.com/help/how-to-ask "How To Ask a Good Question") page for details on how to best help us help you. – itprorh66 Jan 31 '22 at 15:56
  • 2
    Does this answer your question? [facecolor = 'none' (empty circles) not working using seaborn and .map](https://stackoverflow.com/questions/36727614/facecolor-none-empty-circles-not-working-using-seaborn-and-map) However, in this case, [a matplotlib solution](https://stackoverflow.com/a/43519640/8881141) might be better than retrospectively modifying the color scheme automatically applied by seaborn. – Mr. T Jan 31 '22 at 17:00

1 Answers1

1

The following approach loops through the generated dots, and sets their edgecolors to their facecolors. Then the facecolors are set to fully transparent.

import matplotlib.pyplot as plt
import seaborn as sns

tips = sns.load_dataset('tips')
ax = sns.scatterplot(data=tips, x="total_bill", y="tip", hue="day", size="size", sizes=(10, 200))
for dots in ax.collections:
    facecolors = dots.get_facecolors()
    dots.set_edgecolors(facecolors.copy())
    dots.set_facecolors('none')
    dots.set_linewidth(2)
plt.show()

sns.scatterplot with open dots

JohanC
  • 71,591
  • 8
  • 33
  • 66