如何在数据点周围绘制空圆圈?
How can I draw EMPTY circels surrounding the data points?
我想在下面的图中添加围绕每个数据点的空心圆,并设置与第三个变量的值成比例的直径。目前,这是我尝试过的,但是圆圈被填满并覆盖了数据点。使用“facecolors='none'”没有帮助。
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)
以下方法遍历生成的点,并将它们的边缘颜色设置为它们的面颜色。然后将面色设置为完全透明。
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()
我想在下面的图中添加围绕每个数据点的空心圆,并设置与第三个变量的值成比例的直径。目前,这是我尝试过的,但是圆圈被填满并覆盖了数据点。使用“facecolors='none'”没有帮助。
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)
以下方法遍历生成的点,并将它们的边缘颜色设置为它们的面颜色。然后将面色设置为完全透明。
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()