Ggplot,带3行标签的注释图,内部带有粗体文本

时间:2018-10-11 15:29:43

标签: r ggplot2 format

我想将一些居中的文本分成3行,其中第一行为粗体。

我尝试过:

ggplot() + annotate('label', label = 'atop(bold("text1"), "text2\ntext3")', y = 10, x = 10, parse = T, alpha = .75)

但是我得到了

enter image description here

否则:

ggplot() +
    annotate('label', label = 'atop(bold("text1"), atop("text2", "text3"))', y = 10, x = 10, parse = T, alpha = .75)

enter image description here

但是我希望所有3行都具有相同的字体大小。

1 个答案:

答案 0 :(得分:1)

再放一个atop。本质上,如果“分子”中只有一个项目,而“分母”中只有两个垂直项目,那么顶部的项目将大于底部的项目。在分子的分子中需要空白文本。

ggplot() + 
  annotate('label', 
           label = 'atop(atop("", bold("text1")), atop("text2", "text3"))', 
           y = 10, x = 10, parse = T, alpha = .75 )

two atops in an atop