[R-sig-Geo] Lattice PDF two polygon maps per page - help

Jim Burke j.burke at earthlink.net
Fri Apr 17 07:34:20 CEST 2009


Hi everyone, I fixed this myself. I am
posting the fix in case anyone else
has a similar issue.

I found my solution on pp 179-180 in Fig
10.11 in "Lattice Multivariate Data
Visulaization with R" by Deepayan Sarkar.

ACTIONS TAKEN.
1. output both spplot(s) to new frames.
1a.Each frame has a different scale.
2. plot those new frames giving them each
   half a page.
3. Make the titles larger (minor)

CORRECT CODE SNIPPET:

pdf(  file = "myoutputfile.pdf",
      paper= "letter",
      width=8,
      height=10,
      onefile = TRUE,
      bg="white",
      pagecentre=TRUE
   )

library(lattice)
trellis.par.set(sp.theme())

vote_percent <-
spplot(tx3_sp, c("D_PCT"),
    colorkey=list(height=1.0, width=0.6),
    main = list(label="My first title",cex=1),
    line=0,
    sp.layout = list("sp.text",coordinates(tx3_sp),
    as.character(tx3_sp$PCT,cex=.02),
    as.table = TRUE)
 )

total_votes <-
spplot(tx3_sp, c("D_TOT"),
    colorkey=list(height=1.0, width=0.6),
    main = list(label="My second title",cex=1),
    line=0,
    sp.layout = list("sp.text",coordinates(tx3_sp),
    as.character(tx3_sp$PCT, cex=.02),
    as.table = TRUE)
 )

plot(vote_percent, position=c(0, 0.50, 1, 1  ))
plot(total_votes,  position=c(0, 0,    1, .50), newpage = FALSE)
dev.off()

Good luck,
Jim Burke



Jim Burke wrote:
> I would like to print two polygon maps per
> PDF page. The following code prints each
> map on two PDF pages. The maps are small
> enough to print two on one page.
>
> MY QUESTION. How can I get these two polygon
> maps to print on ONE PAGE?
>
> I have Deepayan Sarkar's "Lattice Multivariate
> Data Visulaization with R" book and want to
> do a polygon display like the graphs in Figure
> 1.2.
>
> Using R 2.8.1 latest updates on Windows XP
>
> CODE FRAGMENT FOLLOWS:
>
> pdf(file = "myoutputfile.pdf", width=7, height=10)
>
> library(lattice)                    trellis.par.set(sp.theme())        
> spplot(tx3_sp, c("D_PCT"),
>    colorkey=list(height=1.0, width=0.6),
>    main = list(label="My first title",cex=.5),
>    line=0,
>    sp.layout = list("sp.text",coordinates(tx3_sp),
>    as.character(tx3_sp$PCT,cex=.02),
>    as.table = TRUE)
> )
> spplot(tx3_sp, c("D_TOT"),
>    colorkey=list(height=1.0, width=0.6),
>    main = list(label="My second title",cex=.5),
>    line=0,
>    sp.layout = list("sp.text",coordinates(tx3_sp),
>    as.character(tx3_sp$PCT, cex=.02),
>    as.table = TRUE),
>    newpage = FALSE
> )
> dev.off()
>
> Thanks in advance for your suggestions!
> Jim Burke
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>



More information about the R-sig-Geo mailing list