簡體   English   中英

更改軸標簽中多行之間的距離

[英]Change the distance between multiple lines in axis label

我需要為x軸標簽繪制兩條線。 因為我需要使用特殊字體,所以我選擇使用“表達式”和“atop”。 問題是,如果我只使用“\\ n”,兩條線之間的距離要大得多。 如下:

xlabs <- c('change in log2\nsample A', 
            expression(atop('change in'~log['2'], 'sample B')))

我有這樣的事情:

在此輸入圖像描述

誰知道如何解決問題?

您可以將圖形參數lheightmtext一起使用,以將行間距調整為您想要的任何內容

plot(1:100, xlab = '')
par(lheight = 1.1)
mtext(xlabs[1], side = 1, line = 2)

在此輸入圖像描述

我認為使用表達式向量是我們所要求的:

exl <- list(quote(line~1), quote(line~2))
plot(0:1,0:1,type="n",xlab="")
mtext(side=1, do.call(expression,exl),line=1:2)

這些也取得了成功(並且可能指向更靈活的方法來使用表達式向量:

plot(0:1,0:1,type="n",xlab="")
mtext(side=1, expression(line*1, line*2), line=1:2)

plot(0:1,0:1,type="n",xlab="")
mtext(side=1, c(bquote(line==.(round(exp(1),2))), expression(line*2)), line=1:2)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM