Hi,
I want to put text on a plot containing something like: a = b^2 = <squared numeric value of b> using bquote.
Example:
mu = 5
plot(1:10,1:10)
text(2,8, bquote(delta == mu^2)) # This works
text(2.5,8, bquote(phantom(0) == .(mu^2))) # but is unpredictable
text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
The last text function returns the error:
Error: unexpected '==' in " text(2,8, bquote(delta == mu^2 =="
The first two text functions work in this example, using a default graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
I don't mind the two statements except that when trying to automate this by using the base x coordinate + epsilon*max(x), for example --
x <- 1:10
epsilon=0.05
text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2)))
for the x position on the 2nd text function, the position of the additional text is not predictable.
Thanks,
Larry Hotchkiss
Two == expressions in bquote
6 messages · Larry Hotchkiss, Henrique Dallazuanna, Peter Dalgaard +1 more
Try this: text(2,8, bquote(delta~'='~mu^2 == .(mu^2)))
On Mon, Jan 25, 2010 at 6:00 PM, Larry Hotchkiss <larryh at udel.edu> wrote:
Hi, I want to put text on a plot containing something like: a = b^2 = <squared numeric value of b> using bquote. Example: ?mu = 5 ?plot(1:10,1:10) ?text(2,8, bquote(delta == mu^2)) ? ? ? ? ? ?# This works ?text(2.5,8, bquote(phantom(0) == .(mu^2))) ?# but is unpredictable ?text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work The last text function returns the error: ? ? Error: unexpected '==' in " ?text(2,8, bquote(delta == mu^2 ==" The first two text functions work in this example, using a default graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)). I don't mind the two statements except that when trying to automate this by using the base x coordinate + epsilon*max(x), for example -- ?x <- 1:10 ?epsilon=0.05 ?text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2))) for the x position on the 2nd text function, the position of the additional text is not predictable. Thanks, Larry Hotchkiss
______________________________________________ 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.
Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
Larry Hotchkiss wrote:
Hi,
I want to put text on a plot containing something like: a = b^2 = <squared numeric value of b> using bquote.
Example:
mu = 5
plot(1:10,1:10)
text(2,8, bquote(delta == mu^2)) # This works
text(2.5,8, bquote(phantom(0) == .(mu^2))) # but is unpredictable
text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
The last text function returns the error:
Error: unexpected '==' in " text(2,8, bquote(delta == mu^2 =="
The comparison operators are not associative (they once were, but people
were getting surprises from 3 > 2 > 1 evaluating to TRUE > 1 evaluating
to FALSE). A set of suitably placed braces should clear things up:
text(2,8,bquote(delta == {mu^2 == .(mu^2)}))
The first two text functions work in this example, using a default graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)). I don't mind the two statements except that when trying to automate this by using the base x coordinate + epsilon*max(x), for example -- x <- 1:10 epsilon=0.05 text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2))) for the x position on the 2nd text function, the position of the additional text is not predictable. Thanks, Larry Hotchkiss
______________________________________________ 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.
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
I think that careful examination will show that Henrique's solution is not quite right: the text '=' character is slightly different than the symbol font character. This is admittedly nitpicking, but ... try instead: text(2,8,bquote(paste(delta==mu^2,phantom()==.(mu^2)))) Cheers, Bert Gunter Genentech Nonclinical Biostatistics -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Henrique Dallazuanna Sent: Monday, January 25, 2010 12:10 PM To: Larry Hotchkiss Cc: r-help at r-project.org Subject: Re: [R] Two == expressions in bquote Try this: text(2,8, bquote(delta~'='~mu^2 == .(mu^2)))
On Mon, Jan 25, 2010 at 6:00 PM, Larry Hotchkiss <larryh at udel.edu> wrote:
Hi, I want to put text on a plot containing something like: a = b^2 = <squared
numeric value of b> using bquote.
Example: ?mu = 5 ?plot(1:10,1:10) ?text(2,8, bquote(delta == mu^2)) ? ? ? ? ? ?# This works ?text(2.5,8, bquote(phantom(0) == .(mu^2))) ?# but is unpredictable ?text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work The last text function returns the error: ? ? Error: unexpected '==' in " ?text(2,8, bquote(delta == mu^2 ==" The first two text functions work in this example, using a default
graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
I don't mind the two statements except that when trying to automate this
by using the base x coordinate + epsilon*max(x), for example --
?x <- 1:10 ?epsilon=0.05 ?text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2))) for the x position on the 2nd text function, the position of the
additional text is not predictable.
Thanks, Larry Hotchkiss
______________________________________________ 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.
Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O ______________________________________________ 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.
Peter's way is better than mine. Bert Gunter Genentech Nonclinical Biostatistics -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Peter Dalgaard Sent: Monday, January 25, 2010 12:57 PM To: Larry Hotchkiss Cc: r-help at r-project.org Subject: Re: [R] Two == expressions in bquote
Larry Hotchkiss wrote:
Hi, I want to put text on a plot containing something like: a = b^2 = <squared
numeric value of b> using bquote.
Example:
mu = 5
plot(1:10,1:10)
text(2,8, bquote(delta == mu^2)) # This works
text(2.5,8, bquote(phantom(0) == .(mu^2))) # but is unpredictable
text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work
The last text function returns the error:
Error: unexpected '==' in " text(2,8, bquote(delta == mu^2 =="
The comparison operators are not associative (they once were, but people
were getting surprises from 3 > 2 > 1 evaluating to TRUE > 1 evaluating
to FALSE). A set of suitably placed braces should clear things up:
text(2,8,bquote(delta == {mu^2 == .(mu^2)}))
The first two text functions work in this example, using a default
graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
I don't mind the two statements except that when trying to automate this
by using the base x coordinate + epsilon*max(x), for example --
x <- 1:10 epsilon=0.05 text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2))) for the x position on the 2nd text function, the position of the
additional text is not predictable.
Thanks, Larry Hotchkiss
______________________________________________ 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.
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 ______________________________________________ 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.
You are rigth Bert. Thanks for the clarification.
On Mon, Jan 25, 2010 at 7:00 PM, Bert Gunter <gunter.berton at gene.com> wrote:
I think that careful examination will show that Henrique's solution is not quite right: the text '=' character is slightly different than the symbol font character. This is admittedly nitpicking, but ... try instead: text(2,8,bquote(paste(delta==mu^2,phantom()==.(mu^2)))) Cheers, Bert Gunter Genentech Nonclinical Biostatistics -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Henrique Dallazuanna Sent: Monday, January 25, 2010 12:10 PM To: Larry Hotchkiss Cc: r-help at r-project.org Subject: Re: [R] Two == expressions in bquote Try this: text(2,8, bquote(delta~'='~mu^2 == .(mu^2))) On Mon, Jan 25, 2010 at 6:00 PM, Larry Hotchkiss <larryh at udel.edu> wrote:
Hi, I want to put text on a plot containing something like: a = b^2 = <squared
numeric value of b> using bquote.
Example: ?mu = 5 ?plot(1:10,1:10) ?text(2,8, bquote(delta == mu^2)) ? ? ? ? ? ?# This works ?text(2.5,8, bquote(phantom(0) == .(mu^2))) ?# but is unpredictable ?text(2,8, bquote(delta == mu^2 == .(mu^2))) # This doesn't work The last text function returns the error: ? ? Error: unexpected '==' in " ?text(2,8, bquote(delta == mu^2 ==" The first two text functions work in this example, using a default
graphics window on a 64-bit Windows machine, and either R 2.11.0 development edition for 64-bit Windows or R 9.2.2 on the same machine ((x 86)).
I don't mind the two statements except that when trying to automate this
by using the base x coordinate + epsilon*max(x), for example --
?x <- 1:10 ?epsilon=0.05 ?text(2+esilon*max(x),8, bquote(phantom(0) == .(mu^2))) for the x position on the 2nd text function, the position of the
additional text is not predictable.
Thanks, Larry Hotchkiss
______________________________________________ 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. -- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O ______________________________________________ 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.
Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O