[R] plot log scale, axis original scale

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Apr 9 22:34:12 CEST 2007


Dean Sonneborn wrote:
> I want to produce some boxplots and plot the logged values but have the 
> axis scale in the original, not-logged scale. It seeming like I have the 
> first few steps but I'm having trouble with the last. Here's what I'm 
> doing (which I got for the documentation for boxplot and axis). How do I 
> get the ticks to be labeled 2,5, and 9 of the original scale?
> a<-c(1,2,3,4,5,6,7,8,9,10)
> bcat<-c(1,1,1,2,2,2,2,3,3,3)
> boxplot(log(a)~bcat, yaxt="n")
> axis(2, tick=a)
>
>   
("tick" needs to be TRUE or FALSE!)

Try axis(2, at=log(a), label=a)

Or, maybe, to avoid the "10" label disappearing:

lbl <- a; lbl[9] <- NA; axis(2, at=log(a), label=lbl)



More information about the R-help mailing list