如何将text()与多行字符串一起使用,并从y坐标向下绘制字符串?

时间:2018-06-21 06:47:02

标签: r plot text

如何使两个字符串的顶部在图上对齐?

library(stringr)
arep <- rep('a', 17) %>% 
  str_c(collapse = "\n")
brep <- rep('b', 10) %>% 
  str_c(collapse = "\n")

plot.new()

text(x = .5, y = .5, labels = arep)
text(x = .4, y = .5, labels = brep)

1 个答案:

答案 0 :(得分:0)

尽管这是一种解决方法,但至少这是可行的:

arep <- rep('a', 17) %>% 
  str_c(collapse = "\n")
brep <- c(rep('b', 10), rep("", 7)) %>% 
  str_c(collapse = "\n")

plot.new()
text(x = .5, y = .5, labels = arep)
text(x = .4, y = .5, labels = brep)