[R] log-scale xy-plots

Stefan Stagge stagge.stefan at gmx.de
Fri Nov 30 12:54:00 CET 2012


Hello R-Users, Hello R-help-team.

I found a nice way to create a xy-plot with a single log-axis (e.g. the y-axis). This is often needed to show biological data.

First attach the desired dataset you want to plot.
Now use the following commands:

> plot(x,y,log="y", yaxt="n", ylim=c(0.1,10), ... )
> y1<-floor(log10(range(WT)))
> pow<-seq(y1[1],y1[2]+1)
> ticksat <-as.vector(sapply(pow, function(p) (1:10)*10^p))
> axis(2, 10^pow)
> axis(2, ticksat, labels=NA, tcl=-0.25, lwd=0, lwd.ticks=1)

I want to thank Aaron from http://stackoverflow.com/users/210673/aaron.

I just added the ylim option to create a nice 0.1 to 10 log-axis which is commonly used for biological datasets.

Good luck,
Stefan
-- 
Dipl. Biologe Stefan Stagge

Pengsjövägen 35
91133 Vännäs

mobilephone: +46 762 666401



More information about the R-help mailing list