我需要在 PDF 设备上在页面的最边缘书写。有了这个片段:
pdf('foo.pdf') #Write next plot to foo.pdf in current dire
par(mar=c(0, 0, 0, 0)) #Set numbers of lateral blank lines to zero
par(xaxs='i', yaxs='i') #Does not extend axes by 4 percent for pretty labels
plot.new() #Create a blank plot, as we just want to write our text
text(0, .5, "hello", pos=4, offset=0) #Write to the right with no default 0.5 offset
dev.off() #Close device, that is saving for a PDF device
I get a foo.pdf
with hello
按照预期,在页面中间的最左边,即:
不幸的是,如果我将纸张输出设置为paper='a4'
, 那是:
pdf('foo.pdf', paper='a4') #note the A4 setting
par(mar=c(0, 0, 0, 0))
par(xaxs='i', yaxs='i' )
plot.new()
text(0, .5, "hello", pos=4, offset=0)
dev.off()
hello
不再放在边界上,但是: