gpt4 book ai didi

r - 在 R 中的 A4 PDF 的边框上书写文本

转载 作者:行者123 更新时间:2023-12-04 12:11:42 26 4
gpt4 key购买 nike

我需要在页面的极端边框上的 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

我得到一个 foo.pdfhello在页面中间的最左边,如预期的那样,即:

enter image description here

不幸的是,如果我将纸张输出设置为 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不再放在边界上,但是:

enter image description here

最佳答案

paper设置为除 "special" 以外的其他内容, 参数 pagecentre变得相关。如果您将其设置为 FALSE ,则偏移消失。

pdf('foo.pdf', paper='a4', pagecentre=FALSE)
par(mar=c(0, 0, 0, 0))
par(xaxs='i', yaxs='i' )
plot.new()
text(0, .5, "hello", pos=4, offset=0)
dev.off()

关于r - 在 R 中的 A4 PDF 的边框上书写文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19168471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com