def plot_data2(mX, vClass, vS):
df = pd.DataFrame(mX, columns=['Dim1', 'Dim2'])
df['ls'] = vS-1
df['lc'] = vClass-1
#类别与图例,图例与颜色一一对应
lc = {0:'Left Hand', 1:'Right Hand', 2:'Foot', 3:'Tongue'}
cc = {'Left Hand': 'm', 'Right Hand': 'green', 'Foot': 'orange', 'Tongue':'#424949'}
df['lc'] = df['lc'].map(lc)
ls = {0:'Subject-1', 1:'Subject-2'}
df['ls'] = df['ls'].map(ls)
cs = {'Subject-1': 'red', 'Subject-2': 'blue'}
#设定图片大小
plt.figure(figsize=(10,4))
plt.subplot(1, 2, 2)
sns.scatterplot(x="Dim1", y="Dim2", hue = 'lc', palette= cc, data=df)
plt.legend(loc='best', fontsize=12)
plt.title('By Class')
#去除xy轴的标题
plt.xlabel('')
plt.ylabel('')
plt.subplot(1, 2, 1)
sns.scatterplot(x="Dim1", y="Dim2", hue = 'ls', palette= cs, data=df)
plt.legend(loc='best', fontsize=12)
plt.title('By Subject')
plt.xlabel('')
plt.ylabel('')
plt.show()
seaborn散点图
最新推荐文章于 2024-08-05 23:13:57 发布