[R] Legend

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Nov 25 15:55:20 CET 2011



On 24.11.2011 16:49, Filoche wrote:
> Thank you for your precious help. It works fine.
>
> However, what about if I have two entries in the legend?
>
> I tryed:
>
> legend('topright', inset = .05, title = 'light ratios', pch = c(21,22),
>       legend = c(substitute('Green/Red' ~~ R^2 == r2,
> list(r2=r2)),substitute('Green/Red' ~~ R^2 == r2, list(r2=r2))),
>       horiz = FALSE, pt.bg = c('gray', 'black'), cex = 0.75,
>       bg = 'white')
>
> But it does not work.


There is an example in:

Ligges, U. (2002): R Help Desk: Automation of Mathematical Annotation in 
Plots. R News 2 (3), 32-34.

Applying that to your problem yields:

plot(1)
r2 <- 0.9
termA <- substitute('A: Green/Red' ~~ R^2 == r2, list(r2=r2))
termB <- substitute('B: Green/Red' ~~ R^2 == r2, list(r2=r2))
legend('topright', inset = .05, title = 'light ratios', pch = c(21,22),
        legend = do.call("expression", list(termA, termB)),
        horiz = FALSE, pt.bg = c('gray', 'black'), cex = 0.75,
        bg = 'white')

Best,
Uwe Ligges


> Regards,
> Phil
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Legend-tp4103799p4104386.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



More information about the R-help mailing list