Re: [R] another superscript problem
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.
Re: [R] another superscript problem
Hi, this seems to work, plot.new() legend("topleft", legend=as.expression(c(bquote(.(txt) == .(obv)*degree), "Von Mises distribution"))) HTH, baptiste On 28 December 2010 20:17, Tyler Dean Rudolph wrote: > legend("topleft", legend=c(bquote(.(txt) == .(obv)*degree), "Von Mises > distribution")) __ 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.
Re: [R] another superscript problem
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 On Mon, Dec 27, 2010 at 8:22 PM, Peter Ehlers wrote: > On 2010-12-27 16:51, David Winsemius wrote: > >> >> On Dec 27, 2010, at 6:40 PM, T.D. Rudolph wrote: >> >> >>> I've exceeded the maximum time I am willing to accept for solving >>> simple >>> problems so I thank all in advance for your assistance. >>> >>> I am trying to plot text combined with an object value and a >>> superscript. >>> >>> obv = 5 >>> text = "Population mean =" >>> ss = ^o # degrees >>> >>> Something like this (very naive so you get the idea): >>> expression(text, obv, ss) >>> >>> paste(text, obv) # works ...but of course I either lose the value of >>> obv or >>> the superscript in the translation using expression, and bquote >>> doesn't seem >>> to accept the asterisk before the first element. >>> >> >> I had trouble figuring out your real intent, since you have only been >> describing what didn't work but see if this his halfway there: >> >> plot(1,1) >> obv = 5 >> text = "Population mean =" # you should really avoid using function >> names for variables! >> text(.8,.8, bquote(.(text)~.(obv)^o) ) >> >> The ^o seems a bit of a dodge but it looks ok so if you're happy, go >> > > Instead of ^o, use the word 'degree' (see ?plotmath) > > text(.8,.8, bquote(.(text)~.(obv)*degree) ) > > and, personally, I would let R handle the '=' sign: > > txt <- "Pop mean" > text(1, 1.1, bquote(.(txt) == .(obv)*degree)) > > Peter Ehlers > > with it. >> >>> >>> I am a little bungled by the varying syntax used for bquote and all >>> the >>> rest; sometimes R seems more complicated than it needs to be for a >>> relatively simple problem (and for me this is one of those cases!)... >>> >>> Tyler >>> -- >>> >> >> >> David Winsemius, MD >> West Hartford, CT >> >> __ >> 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. >> > > [[alternative HTML version deleted]] __ 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.
Re: [R] another superscript problem
On 2010-12-27 16:51, David Winsemius wrote: On Dec 27, 2010, at 6:40 PM, T.D. Rudolph wrote: I've exceeded the maximum time I am willing to accept for solving simple problems so I thank all in advance for your assistance. I am trying to plot text combined with an object value and a superscript. obv = 5 text = "Population mean =" ss = ^o # degrees Something like this (very naive so you get the idea): expression(text, obv, ss) paste(text, obv) # works ...but of course I either lose the value of obv or the superscript in the translation using expression, and bquote doesn't seem to accept the asterisk before the first element. I had trouble figuring out your real intent, since you have only been describing what didn't work but see if this his halfway there: plot(1,1) obv = 5 text = "Population mean =" # you should really avoid using function names for variables! text(.8,.8, bquote(.(text)~.(obv)^o) ) The ^o seems a bit of a dodge but it looks ok so if you're happy, go Instead of ^o, use the word 'degree' (see ?plotmath) text(.8,.8, bquote(.(text)~.(obv)*degree) ) and, personally, I would let R handle the '=' sign: txt <- "Pop mean" text(1, 1.1, bquote(.(txt) == .(obv)*degree)) Peter Ehlers with it. I am a little bungled by the varying syntax used for bquote and all the rest; sometimes R seems more complicated than it needs to be for a relatively simple problem (and for me this is one of those cases!)... Tyler -- David Winsemius, MD West Hartford, CT __ 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. __ 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.
Re: [R] another superscript problem
On Dec 27, 2010, at 6:40 PM, T.D. Rudolph wrote: I've exceeded the maximum time I am willing to accept for solving simple problems so I thank all in advance for your assistance. I am trying to plot text combined with an object value and a superscript. obv = 5 text = "Population mean =" ss = ^o # degrees Something like this (very naive so you get the idea): expression(text, obv, ss) paste(text, obv) # works ...but of course I either lose the value of obv or the superscript in the translation using expression, and bquote doesn't seem to accept the asterisk before the first element. I had trouble figuring out your real intent, since you have only been describing what didn't work but see if this his halfway there: plot(1,1) obv = 5 text = "Population mean =" # you should really avoid using function names for variables! text(.8,.8, bquote(.(text)~.(obv)^o) ) The ^o seems a bit of a dodge but it looks ok so if you're happy, go with it. I am a little bungled by the varying syntax used for bquote and all the rest; sometimes R seems more complicated than it needs to be for a relatively simple problem (and for me this is one of those cases!)... Tyler -- David Winsemius, MD West Hartford, CT __ 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.
[R] another superscript problem
I've exceeded the maximum time I am willing to accept for solving simple problems so I thank all in advance for your assistance. I am trying to plot text combined with an object value and a superscript. obv = 5 text = "Population mean =" ss = ^o # degrees Something like this (very naive so you get the idea): expression(text, obv, ss) paste(text, obv) # works ...but of course I either lose the value of obv or the superscript in the translation using expression, and bquote doesn't seem to accept the asterisk before the first element. I am a little bungled by the varying syntax used for bquote and all the rest; sometimes R seems more complicated than it needs to be for a relatively simple problem (and for me this is one of those cases!)... Tyler -- View this message in context: http://r.789695.n4.nabble.com/another-superscript-problem-tp3165591p3165591.html Sent from the R help mailing list archive at Nabble.com. __ 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.