Re: [R] Axis/Ticks/Scale

From: Jim Lemon <bitwrit_at_ozemail.com.au>
Date: Sat 31 Dec 2005 - 13:15:35 EST

R.C.GILL@soton.ac.uk wrote:
> ...
> I would like the axes to be 0,2,4,6,8,10 with a *10^5 on
> the right hand side.
>
> Is there a simple command for this?

This post so interested me that I wrote the following function:

axis.mult<-function(side=1,at=NULL,labels,mult=1,mult.label,mult.line,   mult.labelpos=NULL,...) {
  if(is.null(at)) at<-axTicks(side)
  if(missing(labels)) labels<-at/mult
  axis(side,at,labels,...)
  if(missing(mult.label)) mult.label<-paste("x",mult,collapse="")   # multiplier position defaults to centered on the outside   if(is.null(mult.labelpos)) mult.labelpos<-side   edges<-par("usr")
  if(side %% 2) {
   # either top or bottom
   if(mult.labelpos %% 2) {
    adj<-0.5
    at<-(edges[1]+edges[2])/2
    if(missing(mult.line)) mult.line<-ifelse(mult.labelpos == side,3,0)    }
   else {
    adj<-ifelse(mult.labelpos == 2,1,0)
    at<-ifelse(mult.labelpos == 2,edges[1],edges[2])     if(missing(mult.line)) mult.line<-1
   }
  }
  else {
   # either left or right
   if(mult.labelpos %% 2) {
    adj<-ifelse(mult.labelpos == 1,1,0)
    at<-ifelse(mult.labelpos == 1,edges[3],edges[4])     if(missing(mult.line)) mult.line<-1
   }
   else {
    adj<-0.5
    at<-(edges[3]+edges[4])/2
    if(missing(mult.line)) mult.line=ifelse(mult.labelpos == side,3,0)    }
  }
  mtext(mult.label,side,mult.line,at=at,adj=adj) }

which will be in the next (v2.0.1) version of plotrix.

Jim



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Dec 30 21:16:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:44 EST