Ng Stanley
2008-Apr-10 03:18 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
Hi, I have a 3 by 2 plots per page, and would like to place a legend on the last region. How to do that ? Also, is there any way to specify scientific notation for axes label ? [[alternative HTML version deleted]]
Hans-Jörg Bibiko
2008-Apr-10 05:36 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
On 10.04.2008, at 05:18, Ng Stanley wrote:> Also, is there any way to specify scientific notation for axes label ?Scientific notation ? la 3E-4 is set by default. Or did you mean engineering notation? Maybe this could help: http://wiki.r-project.org/rwiki/doku.php?id=tips:data- strings:formatengineering --Hans
Uwe Ligges
2008-Apr-10 09:08 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
Ng Stanley wrote:> Hi, > > I have a 3 by 2 plots per page, and would like to place a legend on the last > region. How to do that ?Create an empty plot, e.g.: plot(1, type="n", axes=FALSE, xlab="", ylab="") legend(1, 1, legend = c("Hello", "World"), col=1:2, lwd=2, cex=3, xjust=0.5, yjust=0.5) Uwe Ligges> Also, is there any way to specify scientific notation for axes label ? > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.
Uwe Ligges
2008-Apr-10 09:10 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
Uwe Ligges wrote:> > > Ng Stanley wrote: >> Hi, >> >> I have a 3 by 2 plots per page, and would like to place a legend on >> the last >> region. How to do that ? > > > Create an empty plot, e.g.: > > plot(1, type="n", axes=FALSE, xlab="", ylab="") > legend(1, 1, legend = c("Hello", "World"), col=1:2, > lwd=2, cex=3, xjust=0.5, yjust=0.5) > > Uwe Ligges > > > >> Also, is there any way to specify scientific notation for axes label ?Oh, I was too quick and forgot the 2nd question: Use axis() with formatC(). Uwe Ligges>> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >
Stanley Ng
2008-Apr-10 10:33 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
Hi, How can I use formatC to convert 6000000 to 6e5 and not 6e+05 ?> formatC(600000)[1] "6e+05"> formatC(600000, format="e", digit=0)[1] "6e+05" -----Original Message----- From: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de] Sent: Thursday, April 10, 2008 17:11 To: Ng Stanley Cc: r-help Subject: Re: [R] How to create a legend without plot, and to use scientific notation for axes label ? Uwe Ligges wrote:> > > Ng Stanley wrote: >> Hi, >> >> I have a 3 by 2 plots per page, and would like to place a legend on >> the last region. How to do that ? > > > Create an empty plot, e.g.: > > plot(1, type="n", axes=FALSE, xlab="", ylab="") > legend(1, 1, legend = c("Hello", "World"), col=1:2, > lwd=2, cex=3, xjust=0.5, yjust=0.5) > > Uwe Ligges > > > >> Also, is there any way to specify scientific notation for axes label ?Oh, I was too quick and forgot the 2nd question: Use axis() with formatC(). Uwe Ligges>> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >
Hans-Joerg Bibiko
2008-Apr-10 10:57 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
On 10 Apr 2008, at 12:33, Stanley Ng wrote:> How can I use formatC to convert 6000000 to 6e5 and not 6e+05 ? > >> formatC(600000) > [1] "6e+05" >> formatC(600000, format="e", digit=0) > [1] "6e+05"Try this: gsub("([eE])(\\+?)(\\-?)0+", "\\1\\3", formatC(600000, format="e", digit=0)) --Hans
Hans-Joerg Bibiko
2008-Apr-10 11:07 UTC
[R] How to create a legend without plot, and to use scientific notation for axes label ?
On 10 Apr 2008, at 12:57, Hans-Joerg Bibiko wrote:> > On 10 Apr 2008, at 12:33, Stanley Ng wrote: >> How can I use formatC to convert 6000000 to 6e5 and not 6e+05 ? >> >>> formatC(600000) >> [1] "6e+05" >>> formatC(600000, format="e", digit=0) >> [1] "6e+05" > > > Try this: > > gsub("([eE])(\\+?)(\\-?)0+", "\\1\\3", formatC(600000, format="e", > digit=0))Sorry this only works up to e+09 or e-09. This should handle all: gsub("([eE])(\\+?)(\\-?)0*", "\\1\\3", formatC(600000, format="e", digit=0)) --Hans