I have made a plot with a legend and on the screen it looks fine, but
when I save as jpg or pdf, or print, the legend box is too small, it
cuts through the words on the right side.
I put an example here:
http://lark.cc.ukans.edu/~pauljohn/R/apdftest.pdf
Is there a work around?
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I have made a plot with a legend and on the screen it looks fine, but
when I save as jpg or pdf, or print, the legend box is too small, it
cuts through the words on the right side.
I put an example here:
http://lark.cc.ukans.edu/~pauljohn/R/apdftest.pdf
Is there a work around?
You need to tell us a lot more, like which OS, exactly how you saved
or printed, etc.
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.
If you really need to do this you will need to play with the pointsize on
the receiving device.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I have made a plot with a legend and on the screen it looks fine, but
when I save as jpg or pdf, or print, the legend box is too small, it
cuts through the words on the right side.
I put an example here:
http://lark.cc.ukans.edu/~pauljohn/R/apdftest.pdf
Is there a work around?
Sort of. The key is that "replaying" graphics is not smart enough when
a graph is resized, and this effectively happens when you copy a graph
between devices. If your screen image has different (formal)
dimensions and pointsize, the stringwidths used for sizing the legend
box are not recalculated. You can either generate your plots directly
to the target device, or adjust your screen image size to fit the
target using the options to x11()/windows().
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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.
That'll be effective, but would it not work to use
dev.copy(pdf, file="foo", height=7, width=7)
or conversely start the whole enchillada with
x11(height=6, width=6)
??
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._