2016-11-10 96 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") 

默認情況下,觀測行名稱用作點標籤。