On 2010-12-28 11:17, Tyler Dean Rudolph wrote:
Part of the reason I was having difficulty is that I'm trying to add a
legend with more than one element:

plot(1,1)
obv = 5
txt = "Pop mean"

# this works
legend("topleft", legend=bquote(.(txt) == .(obv)*degree))

# but this doesn't
legend("topleft", legend=c(bquote(.(txt) == .(obv)*degree), "Von Mises
distribution"))

How can I go about using multiple legend elements with
mathematical/latin annotation in both?

Tyler

[...snip...]

If you want the secondary text on the same line,
here are 3 ways to do that:

 txt2 <- "(Von Mises distribution)"
 txt3 <- "Von Mises distribution"

 plot(1:10, type='n')
 legend(4,2, legend =
   bquote(.(txt) == .(obv)*degree~~.(txt2)))
 legend(4,4, legend =
   bquote(.(txt) == .(obv)*degree~~group( "(", list(.(txt3)), ")" )))
 legend(4,6, legend =
   bquote(.(txt) == .(obv)*degree~~bgroup( "(", list(.(txt3)), ")" )))

The second and third just produce slightly nicer (I think) parentheses.
For the two-line display use Baptiste's suggestion.
(Note that you can't use \n in plotmath expressions, as per help page.)

Peter Ehlers

______________________________________________
R-help@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.

Reply via email to