[英]sns.scatter plot python, specify size
图例中显示的值似乎与您所说的数据范围在您的 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.