[R] postscript and ps.option metrics

Patrick Mcleod Mcleod at cc.admin.unt.edu
Mon Mar 17 22:39:56 CET 2003


Good Afternoon All,

I am working on a project to generate a particular celeration graph that requires a very specific height and width in the format of the postscript output.

I have attempted to specify my height and width parameters in inches as I found in the R help documentation, but this produces a graph much smaller than what it should if the standard metric is indeed inches.

Since inches do not work, I've tried to "eyeball" the metric by printing out different iterations of the height and width parameters and overlaying a copy of the graph I need on it. This is very time consuming (which I don't mind), inefficient (which I do mind), and tedious (which I do mind) as the width axis (X axis in landscape format) doesn't seem to be moving as the parameter decreases in iterations.

If someone has a few minutes, could you review the code snippet below and provide any suggestions about possible revisions/additions to this? I've looked at it so long I can't tell what might be glaringly wrong or missing.

Many Thanks,

Patrick McLeod
University of North Texas
Denton, TX.

P.S.

The specific axis measurements (in inches) should be: height=5.4, width=8.1 in a landscape format.

# TODO:

#win.graph(width=8.6,height=11.5)

postscript("C:/Data/xxxx.ps", width = 11.6, height = 7.5,
horizontal = TRUE, onefile = TRUE, paper = "letter",
family = "ComputerModern")

# Import Sample Data: Movies IMDB)
 movies <- read.table('xxxxx', header=T, row.names=NULL)
 attach(movies)

# cases <- read.table('xxxxx', header=T, row.names=NULL)
# attach(cases)

# Set up the chart

yticks <- c(1,2,3,4,5,6,7,8,9,
            10,20,30,40,50,60,70,80,90,
            100,200,300,400,500,600,700,800,900,
            1000,2000,3000,4000,5000,6000,7000,8000,9000,
            10000,20000,30000,40000,50000,60000,70000,80000,90000,
            100000,200000,300000,400000,500000,600000,700000,800000,900000,1000000)

myticks <- c(1,10,100,1000,10000,100000,1000000)
mylabs <- c("1","10","100","1,000","10,000","100,000", "1,000,000")

mnyticks <- c(5,50,500,5000,50000,500000)
mnylabs <- c("5","50","500","5,000","50,000","500,000")

xticks <- c(1:100)
#mxticks <- c(0,10,20,30,40,50,60,70,80,90,100)
periods <- c(1900,1905,1910,1915,1920,1925,1930,1935,1940,1945,1950,1955,1960,1965,1970,1975,1980,1985,1990,1995,2000)
mxticks <- c(1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000)
mnxticks <- c(1905,1915,1925,1935,1945,1955,1965,1975,1985,1995)

mxlabs <- c("0","10","20","30","40","50","60","70","80","90","100")

plot(Year,Movies,ylim=c(1,1000000),xlim=c(1902,2002),log='y',type='o',axes=F)

axis(side=2, at=myticks, las=2, labels=mylabs, pos=1900, tck=-0.02)
axis(side=2, at=myticks, pos=1900, tck=.95, labels=F)

axis(side=2, at=yticks, labels=F, pos=1900, tck=0.01)
axis(side=2, at=yticks, labels=F, pos=1900, tck=0.93)

axis(side=2, at=mnyticks, las=2, labels=mnylabs, pos=1900, tck=-0.015, cex=.5)
axis(side=2, at=mnyticks, las=2, labels=F, pos=1900, tck=0.93, cex=.5)

axis(side=1, at=mxticks, pos=1, labels=mxlabs, tck=-0.02)
axis(side=1, at=c(1900:2000), pos=1, labels=F,tck=-0.01)
axis(side=1, at=mnxticks,pos=1, tck=.01, labels=F)
axis(side=1, at=periods, pos=1, tck=.93, labels=F)
axis(side=3, at=mxticks, pos=1000000)

axis(side=4,pos=2000,labels=F,tck=0)

dev.off()



More information about the R-help mailing list