[R] number format in plots

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Oct 9 21:47:25 CEST 2008


Jarek Jasiewicz wrote:
> Hi
> It is probably simple but how to force in plot command number format:
> 20000, 30000, 40000 etc. instead of 2e+04, 3e+04 etc.
>
Not all that simple! It's one of those cases where you need to regain 
some control that you normally leave to the automatics.  What you can do 
is to use one of format(), formatC(), sprintf(),  to get the values  
into the format you want, xaxt="n" to get rid of the default x axis and 
then axis(1, at=value, labels=fvalue).

> example of command:
>
> plot(x=data$along, y=data$rzedna,type="l", xlim=c(0,max(data$along)), 
> ylim=c(200,1200), main="", xlab="length", ylab="height", cex.main=2, 
> cex.lab=1.5, cex.axis=1.2, lwd=2)
>
> thanks
> Jarek
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list