Python 2.7 面部颜色=';无';(空圆圈)使用seaborn和.map不起作用

Python 2.7 面部颜色=';无';(空圆圈)使用seaborn和.map不起作用,python-2.7,matplotlib,plot,seaborn,Python 2.7,Matplotlib,Plot,Seaborn,我有下面的代码,我试图在同一个图上绘制两组数据,标记为空圆。我希望在下面的map函数中包含facecolor='none'来实现这一点,但它似乎不起作用。我能从下面得到的最接近的结果是在红色和蓝色的黑点周围有红色的圆圈 x1 = np.random.randn(50) y1 = np.random.randn(50)*100 x2 = np.random.randn(50) y2 = np.random.randn(50)*100 df1 = pd.DataFrame({'x1':x1, 'y

我有下面的代码,我试图在同一个图上绘制两组数据,标记为空圆。我希望在下面的map函数中包含facecolor='none'来实现这一点,但它似乎不起作用。我能从下面得到的最接近的结果是在红色和蓝色的黑点周围有红色的圆圈

x1 = np.random.randn(50)
y1 = np.random.randn(50)*100
x2 = np.random.randn(50)
y2 = np.random.randn(50)*100

df1 = pd.DataFrame({'x1':x1, 'y1':y1})
df2 = pd.DataFrame({'x2':x2, 'y2':y2})

df = pd.concat([df1.rename(columns={'x1':'x','y1':'y'})
                .join(pd.Series(['df1']*len(df1), name='df')), 
                df2.rename(columns={'x2':'x','y2':'y'})
                .join(pd.Series(['df2']*len(df2), name='df'))],
               ignore_index=True)

pal = dict(df1="red", df2="blue")
g = sns.FacetGrid(df, hue='df', palette=pal, size=5)
g.map(plt.scatter, "x", "y", s=50, alpha=.7, linewidth=.5, facecolors = 'none', edgecolor="red")
g.map(sns.regplot, "x", "y", ci=None, robust=1)
g.add_legend()

sns.regplot
不会传递执行此操作所需的所有关键字,但您可以显式地使用
scatter
执行此操作,关闭
regplot
的scatter,然后重建图例:

g.map(plt.scatter, "x", "y", s=50, alpha=.7,
      linewidth=.5,
      facecolors = 'none',
      edgecolor=['red', 'blue'])


g.map(sns.regplot, "x", "y", ci=None, robust=1,
     scatter=False)

markers = [plt.Line2D([0,0],[0,0], markeredgecolor=pal[key],
                      marker='o', markerfacecolor='none',
                      mew=0.3,
                      linestyle='')
            for key in pal]

plt.legend(markers, pal.keys(), numpoints=1)
plt.show()