[R] several postscript problems
Richard.Cotton at hsl.gov.uk
Richard.Cotton at hsl.gov.uk
Fri Oct 3 12:54:12 CEST 2008
> 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", "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()
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}}
More information about the R-help
mailing list