[程式] R軟體: 有辦法在legend裡兩次使用bquot …

看板Statistics作者 (Mr.Smile)時間14年前 (2011/08/05 18:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
[軟體程式類別]: R [程式問題]: 繪圖 [軟體熟悉度]: 中(3個月到1年) [問題敘述]: 我希望能夠在legend中標兩條線,像下面這樣: ─sigma = 1 ─sigma = 2 以上的sigma想弄成希臘字母 1和2則是希望可以利用變數來設定他的值 本來想利用bquote這個函數 也只能做到標一條線 請問有人可以幫忙修正我的程式嗎?或者有什麼其他方法可以達到我的目的呢? [程式範例]: n1 <- 50 n2 <- 50 sigma1 <- 1 sigma2 <- 2 a <- rlnorm(n1,0,sigma1) b <- rlnorm(n2,0,sigma2) cdf.a <- ecdf(a) cdf.b <- ecdf(b) plot(cdf.a,col=2,main="Empirical CDF of Lognormal Samples") plot(cdf.b,col=3,add=T) legend("bottomright", legend= bquote(sigma == .(sigma1)), col=2, lty=1) # 只有一條線 legend(10,0.2, c(bquote(sigma == .(sigma1)), bquote(sigma == .(sigma2))), col=c(2,3), lty=1) # 這我亂打的,顯然不對 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.152.199 ※ 編輯: yellowleaf 來自: 58.114.169.236 (08/05 21:47) ※ 編輯: yellowleaf 來自: 58.114.169.236 (08/05 21:47)
文章代碼(AID): #1EEyUguP (Statistics)
文章代碼(AID): #1EEyUguP (Statistics)