[R] lattice: formatting tickmark labels of log scaled axes

Deepayan Sarkar deepayan at stat.wisc.edu
Fri Nov 15 23:28:54 CET 2002


On Friday 15 November 2002 10:57 am, Wolfram Fischer wrote:
> Problem:
> 	How can I format tickmark labels of log scaled axes of lattice
> 	graphics in the usual `xxx'-Format (and not in the scientific
> 	format).
>
> Example:
> (according to the help-page of xyplot):
> In the first plot I get the xxx-Format,
> in the second plot I get the scientific format (10^xxx):
>
> 	data(sunspot)
>     plot( 1:37, sunspot, log='y',type='l')
> 	xyplot( sunspot ~ 1:37, type = "l", scales=list(y=list(log=TRUE)) )

There's no direct way to do this (mainly because calculating nicely spaced 
tick positions is somewhat non-trivial, and also to have compatibility with 
Trellis). The ideal workaround is to use something like

xyplot(sunspot ~ 1:37, type = "l", 
       scales=list(y=list(log = TRUE, at = c(5, 10, 20, 50, 100, 200))))

Unfortunately, this seems to be broken in the latest lattice. I'll try to fix 
it, in the meantime you could use 

xyplot(log(sunspot) ~ 1:37, type = "l", 
       scales=list(y=list(at = log(c(5, 10, 20, 50, 100, 200)),
                          labels = as.character(c(5, 10, 20, 50, 100, 200)),
       )))

Deepayan




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list