繁体   English   中英

sns.scatter plot python,指定大小

[英]sns.scatter plot python, specify size

我有下面的 sns.scatterplot,我已将大小设置为 Gap。 出现的间隙值是 0、0.8、0.16 和 0.24,但是我的 dataframe 中的值是 0、0.5、1 和 2。如何将它们设置为等于我的 dataframe 中的值?

ax = sns.scatterplot(x='Number tapes', y='Ic', hue="Angle of twist (degree)", size="Gap", data=Ic_layers)

图例中显示的值似乎与您所说的数据范围在您的 dataframe 中不一致,但无论如何......

您可以在对 scatterplot 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"')

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM