通过使用"\n“作为换行符,我可以得到看起来像附加图像的绘图。然而,问题是8.8e-14。日志要求我将其更改为8.8x10^14 (上标为14 )。然而,这只在我使用表达式(粘贴)时才起作用。但在这种情况下,"\n“不再引起换行。我花了大约5个小时在互联网上尝试和错失不同的解决方案,但都无济于事。有谁有解决方案吗?提前谢谢。
我希望它看起来是什么样子(除了我希望它变成8.8x10^14 ):

除了没有换行符之外,下面的代码都是有效的(我想在“交互”之前换行)
plot_fun_to_revise = function(x, y) {
ggplot(data = data_for_median_plots, aes(x = .data[[x]], y = .data[[y]], group = Secretor, linetype = Secretor)) +
stat_summary(geom = "line", fun.data = median_hilow, size = 0.5) +
stat_sum_df_all("median_hilow",
fun.args = (conf.int = 0.5),
linetype = "solid",
size = 0.5) +
theme_classic()
lnnt_plot_median <- plot_fun_to_revise("Timepoint", "LNnT") +
ylim(0,5000) +
labs(y = paste("LNnT", "(\u03BCg/mL)"),
title = expression(paste("Time p = 8.8 x", 10^-14, ", Secretor p = 0.35, Interaction p = 0.51")),
x = "Time (months postpartum)"发布于 2020-11-26 08:43:39
显然,我没有您的数据来复制图本身,但既然这是关于标签的,我们就创建一个(本质上)空的图:
lnnt_plot_median <- ggplot(data.frame(x = 1, y = 1), aes(x, y)) +
geom_point() +
theme_classic() +
theme(text = element_text(face = 2, size = 16),
plot.title = element_text(hjust = 0.5))由于您已经在使用unicode转义,我认为这里最简单的做法是对上标1和上标4使用unicode转义:
lnnt_plot_median +
labs(y = paste("LNnT", "(\u03BCg/mL)"),
title = paste("Time p = 8.8 x 10\u00b9\u2074,",
"Secretor p = 0.35,\n Interaction p = 0.51"),
x = "Time (months postpartum)")

https://stackoverflow.com/questions/65014328
复制相似问题