[英]line spacing in R/tikz figure annotation
我正在使用Tikz在R中制作人物。 我正在使用mtext將跨越兩行的文本添加到頁邊距。 如何減少mtext生成的兩行文本之間的距離?
這是R腳本的示例:
library("tikzDevice")
outfn<-"LineSpaceingExample.tex"
mydim <- 4
tikz(outfn,standAlone=TRUE,width=mydim,height=mydim)
mytext<- "This is some\nexample text"
x<-c(0, 1)
y<-x
plot(x, y, type = "n")
mtext(text=mytext, side=3,line=0.1)
dev.off()
為了澄清,我想控制“這是一些”和“示例文本”之間的垂直距離。
Googling的另一輪出現了一個解決方案 :在調用mtext
之前減小par()$lheight
。 以下腳本可以達到目的:
library("tikzDevice")
outfn<-"LineSpaceingExample.tex"
mydim<-4
tikz(outfn,standAlone=TRUE,width=mydim,height=mydim)
mytext1<- "This is the default\nline spacing"
mytext2<- "This is modified\nline spacing"
x<-c(0, 1)
y<-x
plot(x, y, type = "n")
mtext(text=mytext1, side=3,line=0.1, at=0.2)
par(lheight=0.8)
mtext(text=mytext2, side=3,line=0.1, at=0.8)
dev.off()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.