2016-11-30 85 views
-1

我想用與變量關聯的國家名稱標註散點圖中的所有點,但所有標籤都向下移動。這不是正確的方式來做到這一點:如何在'抖動'散點圖中標記點

plot(jitter(data$variable1,2), jitter(data$variable2,2), main = "Bivariate relationship between variable1 and variable2", xlim = c(0,100), ylim = c(0,100), xlab = "Variable 1", ylab = "Variable 2", col = "red", pch = 15) 

text(jitter(data$variable1,2), jitter(data$variable2,2), labels = data$Country) 

This is what the scatterplot looks like without labels 而我們的數據是這樣的:

Country Variable1 Variable2 
France  2   2 
Turkey  1   3 
+0

你可以發佈你正在使用的數據,電流輸出,和你預期產出的樣本? – BLT

+0

請先把樣品數據 –

+0

對不起剛編輯過! – Lezako

回答

0

這是否回答您的問題?

Country=c("France", "Turkey") 
Variable1 = c(2, 1) 
Variable2 = c(2, 3) 
df = data.frame(Country, Variable1, Variable2) 
x1=jitter(Variable1, 2);x2=jitter(Variable2, 2) 
plot(x1, x2, xlim = c(min(x1)-1, max(x1)+1), ylim=c(min(x2)-1, max(x2)+1)) 
text(x1,x2, labels=df$Country, cex=.7, pos=3) 

enter image description here