R:完全合理的包装

时间:2018-07-28 11:57:50

标签: r

有一个包装文本的函数示例 参考:Text wrap for plot titles 但是,如何使文本左右对齐呢?  (对齐-文本沿左边缘对齐,并调整字母和单词间距,以使文本与两个边缘齐平,也称为完全对齐或完全对齐)。

plot(rnorm(100), main = paste(
strwrap(
'This is a very long title wrapped on multiple lines without the need to adjust it by hand',
whitespace_only = TRUE,
width = 50
  ),
 collapse = "\n"
))

1 个答案:

答案 0 :(得分:5)

这是帮助页面?par中描述的标准绘图参数。对于左对齐,您需要参数adj = 0

plot(rnorm(100), main = paste(
strwrap(
'This is a very long title wrapped on multiple lines without the need to adjust it by hand',
width = 50), collapse = "\n" ), adj=0)

Left Justified title

对于右对齐,请使用adj=1