【发布时间】:2019-06-04 02:10:22
【问题描述】:
将文本添加到 R 中绘图/图形的特定位置。
你好。我在 R 中制作了一系列图。我想节省空间,所以我想删除我之前使用“main”命令的标题。
我想将标题放在绘图/图表的顶部中间。
在网上查找时,我发现了放置文本的好代码,如下所示:http://sphaerula.com/legacy/R/placingTextInPlots.html
## par( "usr" ) returns a vector containing xleft, xright, ybottom, ytop.
usr <- par( "usr" )
## Place the text. Note the use of the adj parameter.
## Left top corner:
text( usr[ 1 ], usr[ 4 ], "left top", adj = c( 0, 1 ), col = "blue" )
## Left bottom corner:
text( usr[ 1 ], usr[ 3 ], "left bottom", adj = c( 0, 0 ), col = "blue" )
## Right top corner:
text( usr[ 2 ], usr[ 4 ], "right top", adj = c( 1, 1 ), col = "blue" )
## Right bottom corner:
text( usr[ 2 ], usr[ 3 ], "right bottom", adj = c( 1, 0 ), col = "blue" )
所有这些命令都将文本放在特定的角落。我想把它放在中间。有没有关于如何做到这一点的建议?一种原始的方法是在左上角的文本中添加大量空格......但是还有什么更优雅的吗?
【问题讨论】: