[R] box doesn't surround words in legend in printed output

Paul E Johnson pauljohn at ukans.edu
Wed Aug 8 21:36:10 CEST 2001


Prof Brian Ripley wrote:

> You need to tell us a lot more, like which OS, exactly how you saved
> or printed, etc.

I thought you knew me:)  I have: Linux, RH 7.1, R version 1.3 installed
from the RPM on R's homepage.

> My guess though is that you copied from device to device.  Don't,
> use plot directly on the device you wanted.  Copying plots does not
> recalculate boxes for changed point sizes, for example.

Yes, you are correct.  I was using dev.copy().  I notice now dev.print()
gives a better result, I should have remembered.

Perhaps one of you will tell me if there is a standard recommended way
to do this. I will eagerly follow any advice you have.  I'll even
document it(http://lark.cc.ukans.edu/~pauljohn/R/statsRus.html#5.2).  

Here is the goal:
I have hundreds of datasets, DataCulture0, DataCulture1, etc, and I
cycle through them to try to find the one that has the pattern I'm
looking for. This does it:

run<-0
updateDataSet <- function(run)
  {
    aChar<-character(1)
    aChar<-as.character(run)
    dsname<-c(paste("DataCulture",aChar,sep=""))
    data<-read.table(dsname,header=T,as.is = TRUE)
}

buildGraph <-function(data)
{
tmp1<-plot(data$acquaint~data$T,type='l', ylim=c(0,1),ylab="average
proportion",xlab="PERIOD",lty=1,pch=1,main="")
par("new"=TRUE)
tmp2<-plot(data$harmony~data$T,type='l', ylim=c(0,1),ylab="average
proportion",xlab="PERIOD",lty=2,pch=1,main="")
par("new"=TRUE)
tmp3<-plot(data$identical~data$T,type='l', ylim=c(0,1),ylab="average
proportion",xlab="PERIOD",lty=3,pch=1,main="")
par("new"=TRUE)
tmp4<-plot(data$totalEntropy~data$T,type='l',ylim=c(0,1),ylab="",xlab="",lty=4,pch=1,main="",
cex=10)

legend(max(data$T)/2,0.2,c("Acquaintance","Harmonious","Identical","Entropy"),lty=1:4,xjust=1,yjust=1)
#if you want to interact, do this:
#legend(locator(1),c("Acquaintance","Harmonious","Identical","Entropy"),lty=1:3)
}

new<-function()
{
  dsname<-updateDataSet(run)
  buildGraph(dsname)
  run <<- run+1
}

new()

Each time I type 
new()
it opens the next dataset and makes me a plot that I see on the screen.
When I see the one I want, then I need to save it. 

Perhaps I should make a function that turns on the pdf device, then
replots the figure, then turns the device off.

-- 
Paul E. Johnson                       email: pauljohn at ukans.edu
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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