[R] plotting on a reverse log scale

Spencer Graves spencer.graves at pdf.com
Wed Jul 6 22:04:28 CEST 2005


	  Do you want to move year 2000 to Inf?  How about a cube root 
transformation instead:

year <- seq(0, 4000, 100)
y2000.3 <- (sign(year-2000)*
             abs(year-2000)^(1/3))
plot(y2000.3, year, axes=FALSE)
axis(1, y2000.3, year)
axis(2)

	  Of course, one should package the transformation in a function  and 
more carefully select the tick marks, but a little study of the help 
pages for the functions in this example should suffice for that.

	  spencer graves

Michael Friendly wrote:

> I'd like to do some plots of historical event data on a reverse log 
> scale, started, say at the year 2000 and going
> backwards in time, with tick marks spaced according to log(2000-year).  
> For example, see:
> 
> http://euclid.psych.yorku.ca/SCS/Gallery/images/log-timeline.gif
> 
> As an example, I'd like to create a density plot of such data with the 
> horizontal axis reverse-logged,
> a transformation of this image:
> http://euclid.psych.yorku.ca/SCS/Gallery/milestone/Test/mileyears1.gif
> 
> Some initial code to do a standard density plot looks like this:
> 
> mileyears <- read.csv("mileyears3.csv", skip=1, 
> col.names=c("key","year","where","add","junk"))
> mileyears <- mileyears[,2:4]
> 
> years <- mileyears$year
> years1500 <- years[years>1500]
> dens <- density(years1500, from=1500, to=1990)
> plot(dens)
> rug(years1500)
> 
> I could calculate log(2000-year), but I'm not sure how to do the 
> plotting, do some minor tick marks
> and label the major ones, say at 100 year intervals.
> 
> thanks,
> -Michael
> 
> 
>  
> 

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list