[R] axes labeling
William Dunlap
wdunlap at tibco.com
Thu Dec 20 22:03:15 CET 2012
By "too much control" do you mean that axis requires too many inputs?
You can use axTicks to get the positions of the tick marks that would have
been drawn and create labels based on those positions. E.g.,
> myAxis <- function (side) {
at <- axTicks(side = side)
lab <- ifelse(abs(at)>=1e6, paste(at/1e6, "M"), paste0(at/1e3, "k")) # alter to suit your tastes
axis(side = side, at = at, lab = lab)
}
> plot(c(1,1200), c(1,1e6), axes=FALSE)
> myAxis(side=1) # "0k", "0.2k", ..., "1.2k" on x axis
> myAxis(side=2) # "0k", ..., "800k", "1M" on y axis
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Sam Steingold
> Sent: Thursday, December 20, 2012 11:22 AM
> To: r-help at r-project.org
> Subject: [R] axes labeling
>
> Is it possible to control formatting of the numbers which go along the
> axes in plots?
> e.g.
> plot(x=1:1000000,y=1:1000000)
> will label the X axis as "0d+00", "2e+05" &c.
> I want that to read 0, 200k, 400k &c.
> I know of the function axis(), but it offers far too much control for
> this simple task.
> thanks.
> --
> Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
> http://www.childpsy.net/ http://www.memritv.org http://jihadwatch.org
> http://pmw.org.il http://americancensorship.org http://think-israel.org
> Why do we want intelligent terminals when there are so many stupid users?
>
> ______________________________________________
> 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