散点图标签重叠 - matplotlib

时间:2017-08-18 04:42:35

标签: python pandas matplotlib scatter

我想用标签绘制散点图。但是,这些标签是重叠的。如何增强其外观以便更好地查看数字?另外,我有整数的数字,但它在float中显示标签值。我想知道为什么。

期待收到你们的回复。

这是我的代码:

col = df['type'].map({'a':'r', 'b':'b', 'c':'y'})
ax = df.plot.scatter(x='x', y='y', c=col)

df[['x','y','id']].apply(lambda x: ax.text(*x),axis=1)

enter image description here

1 个答案:

答案 0 :(得分:1)

我建议您安装adjustText软件包:

python -m pip install adjustText

,然后跟随this old Stackoverflow answer

相关问题