作者yellowleaf (Mr.Smile)
看板Statistics
标题[程式] R软体: 有办法在legend里两次使用bquote吗?
时间Fri Aug 5 18:36:23 2011
[软体程式类别]:
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)