[R] legend with math (greek letters) symbols
David Winsemius
dwinsemius at comcast.net
Sun Sep 14 06:04:17 CEST 2014
On Sep 13, 2014, at 5:55 PM, Julio Sergio Santana wrote:
> I need to add a legend with three entries that should
> contain a greek letter (lambda). I learnt that it is
> possible using the function expression. So I need to
> build the expressions from the lambdas vector, and I
> simply cannot do it. This is the uggly result I got:
>
>
> x <- 0:20
> cc <- c("yellow", "springgreen", "navyblue")
> lambdas <- c(6, 10, 13)
> ds <- as.data.frame(lapply(lambdas, function(ll) dpois(x, ll)))
> names(ds) <- lambdas
> funcs <- list(plot, lines)
>
> for (i in 1:3) {
> ff <- funcs[[1+(i!=1)]]
> ff(x,ds[[i]], type="o", pch=21,bg=cc[i])
> }
>
> # I can't build the expressions:
> q <- list(expression(lambda==6), expression(lambda==10),
> expression(lambda==13))
>
> legend("topright",
> legend=q,
> lty=1, pch=21, pt.bg=cc)
q <- expression(lambda==6, lambda==10 ,lambda==13)
legend("topright",
legend=q,
lty=1, pch=21, pt.bg=cc)
--
David.
>
> legend() doesn't interpret the expressions and then it doesn't show
> the lambda symbol.
>
> Do you have any comments on this?
>
> Thanks,
>
> -Sergio.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list