[R] Graphics Reciprocal labeling

Jim Lemon jim at bitwrit.com.au
Sat Oct 29 05:32:00 CEST 2011


On 10/29/2011 09:23 AM, Hurr wrote:
> Can I also label selected reciprocal numbers easily either
> alongside or without the automatic ones, and have them
> automatically in their correct spots.
> Sorry, I really don't know R now.
>
Hi Hurr,
What you want is probably achievable with the "axis" function. The idea 
is not to display the X axis (xaxt="n") in the initial plot command and 
then add the custom axis later. To give a simple example:

plot(1:10,xaxt="n")
axis(side=1,at=1:10,round(labels=1/1:10,2))

or if you want fraction notation:

axis(side=1,at=1:10,labels=paste(1,1:10,sep="/"))

If you want to have both the original numbers and the fractions:

axis(side=1,at=1:10,padj=0.3,
  labels=paste(1:10,paste(1,1:10,sep="/"),sep="\n"))

and so on. The important things to remember are, "at" is where the 
labels will be placed and "labels" is what they will look like.

Jim



More information about the R-help mailing list