Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White space when printing full page world map plot

Tags:

r

pdf

I am trying get a full page plot of a world map on a A4 landscape PDF. When I use the following

pdf("temp.pdf", paper="a4r")
#par(mar=rep(0,4))
map("world", mar = rep(0,4))
dev.off()

I get

enter image description here

I can not seem to get the plot to fill the page. Any tips?

like image 219
guyabel Avatar asked Jan 27 '26 07:01

guyabel


2 Answers

Try:

pdf("temp.pdf", paper="a4r",width=0,height=0)
map("world")
dev.off()

which looks odd but works, and is mentioned in the docs. It gives me a world map that fills the page left-right, but not top-bottom because it is keeping the aspect ratio.

like image 175
Spacedman Avatar answered Jan 29 '26 00:01

Spacedman


You could extract coordinates:

coord <- map.poly(database="world", regions=".", exact=FALSE,
        xlim=NULL, ylim=NULL, boundary=TRUE, interior=TRUE, fill=FALSE,
        as.polygon=TRUE)

and then plot whatever you want with coord$x and coord$y.

like image 28
danas.zuokas Avatar answered Jan 28 '26 23:01

danas.zuokas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!