[問題] 想解決字在圖上 overlapping
- 問題: 當你想要問問題時,請使用這個類別
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
入門(寫過其他程式,只是對語法不熟悉)
[問題敘述]:
我在繪製scatter plot時候,想要把每一個點的ID標在旁邊,但直接用text()函數,
則有一些太近的點的ID就會重疊在一起,想請教一下有沒有package/ function
可以解決這問題,畫比較精美的圖 感謝!
[程式範例]:
a <- c(rnorm(10,-3,2),rnorm(10,3,2))
b <- c(rnorm(10,-3,2),rnorm(10,3,2))
dfr <- data.frame(a,b)
dfr$t <- c(paste("A",1:10,sep=""),paste("B",1:10,sep="")) #ID of points
dfr[1,1]=dfr[5,1]+rnorm(1,0,0.0001)
dfr[1,2]=dfr[5,2]+rnorm(1,0,0.0001)
dfr[7,1]=dfr[10,1]+rnorm(1,0,0.0001)
dfr[7,2]=dfr[10,2]+rnorm(1,0,0.0001)
plot(dfr$a,dfr$b,main="Plot")
text(dfr$a+0.5,dfr$b+0,5,dfr$t)
[關鍵字]:
scatter plot, text, overlapping, plot, text
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.245.65.135
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1453024733.A.16E.html
※ 編輯: ming790925 (60.245.65.135), 01/17/2016 18:05:31
※ 編輯: ming790925 (60.245.65.135), 01/17/2016 18:06:16
→
01/17 22:13, , 1F
01/17 22:13, 1F
→
01/17 22:27, , 2F
01/17 22:27, 2F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章