Skip to content

plotting on map

2 messages · Dr. Alireza Zolfaghari, Michael R. Head

#
On Mon, 2009-03-02 at 23:15 +0000, Dr. Alireza Zolfaghari wrote:
How about this:


library(maps)
    require("mapproj")
    longlatLimit<-c(-106.65,  -93.53 ,  25.93 ,  36.49)
    par(plt=c(0,1,0,1),cex=1,cex.main=1)  #Set plotting parameters
    map(projection="azequalarea", type="n",xlim=longlatLimit[1:2],ylim=longlatLimit[3:4])
    bound<-c(floor(longlatLimit[1]), ceiling(longlatLimit[2]), floor(longlatLimit[3]), ceiling(longlatLimit[4]))
    map.grid(lim=bound,col="light grey")
when I wrap the above in 
pdf("test.pdf")
...
dev.off()

I see the full PDF, though there is extra space on the page around it.

I frequently use pdf2ps to get the tight bounds on the graphic when I'm
including it in latex:
$ pdf2ps test.pdf - | grep "^%%BoundingBox:[0-9 ]*$" | cut -f 2- -d ' '
84 222 452 493

which can be used like so: 
\includegraphics[width=0.9\linewidth,viewport=84 222 452 493]{test}