【发布时间】:2018-05-13 09:07:00
【问题描述】:
情况:
我有一个 ggplot 图,我想在其中添加一些文本注释。文本注释应该出现在两行中(为了可读性和空间),并且每一行都包含一些 TeX 公式:
library(tidyverse)
library(latex2exp)
ggplot(NULL, aes(c(-5,5))) +
geom_area(stat = "function", fun = dnorm, fill = "grey40", xlim = c(-2, 2)) +
annotate(geom = "text", label = TeX(paste("Distribution of $\\bar{x}$","\n","under $H_0$")),
x = -1, y = 0.3,
color = "red")
问题:
换行符不显示。该行没有分成两行。
什么不起作用:
我试过paste(TeX(...))和parse = T,都没有成功。
我也试过这个label = expression(paste("distribution of ", bar(x), "\n", "under H0"))查here,没有成功。
问题:
如何将注释(红色文本)分成两行?
【问题讨论】:
标签: r ggplot2 latex line-breaks plotmath