labeling log plots neatly

5 views
Skip to first unread message

greg.j...@weyerhaeuser.com

unread,
Mar 19, 2009, 1:33:45 PM3/19/09
to Forest-R
As I advance in years things are never as obvious as they one were.
Here's a quick summary of some clean ways to label log scales on
trellis graphs.

To plot some points using a log y axis you cannot use the normal
graphics idiom of:

xyplot( c(1:100)~c(1:100), log="y" ) # this doesn't work

Rather you have to set the scales list appropriately:

xyplot( c(1:100)~c(1:100), scales=list(y=list(log=10)) ) # this works

However, the y axis is labeled 10^0, 10^1, 10^2 ... While correct,
it's generally not what we expect to see. To correct it just add an
"at" list to the scales y list:

xyplot( c(1:100)~c(1:100), scales=list(y=list(log=10,at=c
(1,10,100))) )

Voila!
Reply all
Reply to author
Forward
0 new messages