我有下面的sns.scatterplot,我已经将大小设置为Gap。出现的Gap值是0、0.8、0.16和0.24,但是我的数据帧中的值是0、0.5、1和2。我如何将它们设置为与我的数据帧中的值相等?
ax = sns.scatterplot(x='Number tapes', y='Ic', hue="Angle of twist (degree)", size="Gap", data=Ic_layers)
发布于 2020-04-25 16:54:56
图例中显示的值似乎与您所说的数据范围不一致,但不管怎样...
您可以在对scatterplot()
的调用中使用legend='full'
来强制seaborn为您的色调/大小变量的每个级别显示一个图例项。
N=50
df = pd.DataFrame({'x': np.random.random(size=(N,)), 'y': np.random.random(size=(N,)),
'size': np.random.choice([0, 0.5, 1, 2], size=(N,))})
fig, (ax1, ax2) = plt.subplots(1,2)
sns.scatterplot(x="x", y="y", size="size", data=df, ax=ax1)
ax1.set_title('legend="brief" (default)')
sns.scatterplot(x="x", y="y", size="size", data=df, legend='full', ax=ax2)
ax2.set_title('legend="full"')
https://stackoverflow.com/questions/61422624
复制相似问题