[R] Graphics Reciprocal labeling

David Winsemius dwinsemius at comcast.net
Fri Oct 28 22:20:40 CEST 2011


On Oct 28, 2011, at 3:57 PM, Hurr wrote:

> Does R graphics have a way to easily label the horizontal axis by the
> reciprocal of the scaled value?

  plot(x<-1:10,y<-1:10, xaxt="n")
  axis(1, at=1:10, labels=round(1/x, 3) )


It is a bit more difficult to do it as a fractional label but possible:

  rm(x)
  plot(x<-1:10,y<-1:10, xaxt="n")
xepr <- as.expression( sapply(x, function(y) bquote(frac(1, .(y) )) ))
  axis(1, at=1:10, labels=xepr )
>

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list