2016-11-10 92 views
0

我试图将标签放在绘图中的数据点上,该图找到人口最少的前5个国家。将标签添加到绘图上的数据点R

Smallestpop.order = order(population$X2014) 
smallref = population[Smallestpop.order,] 
smallref[1:5,] 
plot(smallref[1:5,3:,]) 
text(smallref[1:5],labels=smallref$Country.Code[1:5],adj = NULL, 
pos = 1, offset = 0.5, vfont = NULL, 
cex = 1, col = NULL, font = NULL) 

这是目前情节看起来像

enter image description here

,但我想对每一个数据点的国家代码。 这可能吗?

+0

分享一个可重现的数据供我们使用! –

回答

0

scatterplotMatrix()car包中有一个arg id.n控制点标记和id.method provyp各种方法。

你想使用类似

scatterplotMatrix(population, id.n=5, id.method="y") 

默认情况下,观测行名称用作点标签。