Hello everyone, I'm currently trying to export a couple of graphs to pdf . Postscript would be fine too, but I'm using odd page dimensions, which seem to be overwritten when using the "ps2pdf" command. I'm using the pdfpages package in LaTeX to put 6 graphs onto one page (this is why it ought to be a pdf in the end). I have two problems: 1. I'm using "arrows" to add error bars to the plots and they come out all misplaced. I've read in older posts that this might be solved using Acrobat Reader, but would this mean that I have to teach LaTeX (Lyx) somehow to use Acrobat too? 2. I'm also using a legend that includes some dots (pch=1, pch=19), which pdf obviously doesn't understand and plots little q symbols instead (postscript will understand these symbols). Do I have to load a certain font to get it to work? Joanne > sessionInfo() R version 2.7.1 (2008-06-23) i386-redhat-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Examples: R: pdf("result.pdf",height=4,width=4) ... ### plot empty window plot(0,0, type="n", ylim=c(-180,180), xlim=c(0,0.5), xlab="", ylab="Phase", xaxt="n", yaxt="n") axis(1,at=seq(0,0.5,0.1),label=rep(" ",6)) axis(2,at=seq(-180,180,90)) abline(h=0,lty=3) legend("topright",c("annual means", "summer means"),pch=c(19,1),cex=1) ### plot with error bars in loop plot(get(site[j,i])[k,1],get(site[j,i])[k,3],pch=19,axes=F,ann=F,ylim=c(-180,180),xlim=c(0,0.5),col=plotcolour[i]) arrows(get(site[j,i])[k,1],get(site[j,i])[k,3]+get(site[j,i])[k,4],get(site[j,i])[k,1],get(site[j,i])[k,3]-get(site[j,i])[k,4],length = .03, angle = 90, code = 3,col=plotcolour[i]) ... dev.off() LaTeX: \includepdf[pages={1-6},pagecommand={\thispagestyle{fancy}\begin{figure}[!b]\caption{test}\end{figure}},nup=2x3,scale=0.75,offset={0.5cm 1cm}]{result.pdf}
On Fri, 3 Oct 2008, Joanne Demmler wrote:> Hello everyone, > > I'm currently trying to export a couple of graphs to pdf . Postscript would > be fine too, but I'm using odd page dimensions, which seem to be overwritten > when using the "ps2pdf" command. I'm using the pdfpages package in LaTeX to > put 6 graphs onto one page (this is why it ought to be a pdf in the end). > > I have two problems: > > 1. I'm using "arrows" to add error bars to the plots and they come out all > misplaced. I've read in older posts that this might be solved using Acrobat > Reader, but would this mean that I have to teach LaTeX (Lyx) somehow to use > Acrobat too?Almost certainly a bug in your PDF viewer. Presumably you are using pdftex (the program) as your TeX engine, and that passes the inputted PDF code through. The suggestion is to view the final PDF in Acrobat Reader or ghostview, and not viewers based on xpdf.> 2. I'm also using a legend that includes some dots (pch=1, pch=19), which pdf > obviously doesn't understand and plots little q symbols instead (postscript > will understand these symbols). Do I have to load a certain font to get it to > work?The problem is not 'pdf' but most likely your broken PDF viewer. I've seen this one a few times. R 2.8.0 alpha has an option in pdf() to work around this particular viewer bug, but do you really want to be using such a viewer?> Joanne > > >> sessionInfo() > R version 2.7.1 (2008-06-23)Not current -- see the posting guide!> i386-redhat-linux-gnu > > locale: > LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > > Examples: > R: pdf("result.pdf",height=4,width=4) > ... > ### plot empty window > plot(0,0, type="n", ylim=c(-180,180), xlim=c(0,0.5), xlab="", ylab="Phase", > xaxt="n", yaxt="n") > axis(1,at=seq(0,0.5,0.1),label=rep(" ",6)) > axis(2,at=seq(-180,180,90)) > abline(h=0,lty=3) > legend("topright",c("annual means", "summer means"),pch=c(19,1),cex=1) > > ### plot with error bars in loop > plot(get(site[j,i])[k,1],get(site[j,i])[k,3],pch=19,axes=F,ann=F,ylim=c(-180,180),xlim=c(0,0.5),col=plotcolour[i]) > arrows(get(site[j,i])[k,1],get(site[j,i])[k,3]+get(site[j,i])[k,4],get(site[j,i])[k,1],get(site[j,i])[k,3]-get(site[j,i])[k,4],length > = .03, angle = 90, code = 3,col=plotcolour[i]) > ... > dev.off()This is not reproducible, or I would have tried it.> LaTeX: > \includepdf[pages={1-6},pagecommand={\thispagestyle{fancy}\begin{figure}[!b]\caption{test}\end{figure}},nup=2x3,scale=0.75,offset={0.5cm > 1cm}]{result.pdf} > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> I'm currently trying to export a couple of graphs to pdf . Postscript > would be fine too, but I'm using odd page dimensions, which seem to be > overwritten when using the "ps2pdf" command. I'm using the pdfpages > package in LaTeX to put 6 graphs onto one page (this is why it ought to > be a pdf in the end). > > I have two problems: > > 1. I'm using "arrows" to add error bars to the plots and they come out > all misplaced. I've read in older posts that this might be solved using > Acrobat Reader, but would this mean that I have to teach LaTeX (Lyx) > somehow to use Acrobat too? > > 2. I'm also using a legend that includes some dots (pch=1, pch=19), > which pdf obviously doesn't understand and plots little q symbols > instead (postscript will understand these symbols). Do I have to load a > certain font to get it to work?> Examples: > R: pdf("result.pdf",height=4,width=4) > ... > ### plot empty window > plot(0,0, type="n", ylim=c(-180,180), xlim=c(0,0.5), xlab="", > ylab="Phase", xaxt="n", yaxt="n") > axis(1,at=seq(0,0.5,0.1),label=rep(" ",6)) > axis(2,at=seq(-180,180,90)) > abline(h=0,lty=3) > legend("topright",c("annual means", "summermeans"),pch=c(19,1),cex=1)> > ### plot with error bars in loop > plot(get(site[j,i])[k,1],get(site[j,i])[k,3],pch=19,axes=F,ann=F, > ylim=c(-180,180),xlim=c(0,0.5),col=plotcolour[i]) > arrows(get(site[j,i])[k,1],get(site[j,i])[k,3]+get(site[j,i])[k,4], > get(site[j,i])[k,1],get(site[j,i])[k,3]-get(site[j,i])[k,4],length > = .03, angle = 90, code = 3,col=plotcolour[i]) > ... > dev.off()In order to solve this, you need to work out if the problem is with R, or with Latex. Try creating a pdf, and viewing that directly, without incorporating it into a Latex document. You may also want to try some simpler plots, to check that you can display the correct pch figures and arrows properly. Test 1 plot(1:10, pch=c(1,19)) Do the dots display okay? Test 2 pdf("test2.pdf") plot(1:10, pch=c(1,19)) dev.off() Are they still okay? Test 3 pdf("test3.pdf") plot(1:10) arrows(10,1,1,10) dev.off() Is the arrow in the right place? Test 4 Plot your more complex figure on screen, is it all okay? Test 5 Now write to pdf. Test 6 Now incorporate into Latex doc. Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
> I'm currently trying to export a couple of graphs to pdf . > Postscript would be fine too, but I'm using odd page dimensions, > which seem to be overwritten when using the "ps2pdf" command.From what you wrote I guess that perhaps you don't really want unusual page dimensions, but rather Encapsulated PostScript files, which are automatically cropped to their bounding box and can be included as images in a latex document (using \includegraphics or such, so you could arrange the 6 graphs in a standard latex figure environment etc.; and, of course, there's no need to go through PDFs). If that's what you want to do, simply use dev.copy2eps(), setting width= and height= to the desired format of the plot and remembering to specify onefile=FALSE (that's a trap I keep falling into ...). If you still need PDFs, use the "epstopdf" program for the conversion, because ps2pdf will usually mess up your bounding box and revert to a standard page size. Best regards, Stefan Evert [ stefan.evert at uos.de | http://purl.org/stefan.evert ]