![](/img/trans.png)
[英]Add a custom label and tick to categorical y-axis of tile-plot in ggplot2
[英]mtext y-axis label that covers a two-tile plot
在下面的示例中mtext(side = 2,text="y-axis")
如何使用mtext(side = 2,text="y-axis")
為兩個圖塊放置y軸標簽? 也就是說,我希望能夠放置一個標簽,而不是放置兩個單獨的y軸標簽。
layout(matrix(1:2,ncol=1),widths=1,heights=c(2,2),respect=FALSE)
par(mar = c(0, 4.1, 4.1, 2.1))
plot(rnorm(100),main="Hi",type='l',ylab='',xaxt='n')
par(mar = c(4.1, 4.1, 0, 2.1))
plot(rnorm(100),main="",xlab="Hi",type='l',ylab='')
正確的方法是使用par(oma=...)
添加外邊距 ,使用ann=FALSE
抑制注釋,然后使用mtext(..., outer=TRUE)
在外邊距中手動添加它們。
layout(matrix(1:2,ncol=1),widths=1,heights=c(2,2),respect=FALSE)
par(mar = rep(0, 4), oma=c(4, 4, 4, 2), las=1)
plot(rnorm(100), type='l', ann=FALSE, xaxt='n')
plot(rnorm(100), type='l', ann=FALSE)
title("Hi", outer=TRUE)
mtext("x-axis", 1, 3, outer=TRUE)
mtext("y-axis", 2, 3, outer=TRUE, las=0)
這是一個參考: http : //research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/
還要注意使所有標簽水平的las
參數。 它讓它更容易閱讀並向您的觀眾展示您知道的情節:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.