如何解决在ggpubr中包装部分加粗和斜体的主标题-ggerrorplot
我无法获得任何包装主图标题以使其包含一些粗体和斜体字的标题的解决方案。在其他几种无济于事的解决方案中,我尝试过Stringr并手动创建换行符,但是stringr包含“粗体”等。文本和手动换行符要么不产生任何效果,要么创建非常奇怪的中断strange manual break(我已经在几个地方尝试过它们,看看是否有任何效果。
对不起笨拙的代码-我是生物学研究生,对R来说还很陌生。
mainplotlabel4 <- c(expression(paste(bold("Figure 5"),italic(" Species with long name")," Long fake name virginica response all things"),italic(" Shorter species")," Sepal Length Only Purple Long Fake Name"))
setosa.sepal.dotplot <- ggerrorplot(data = iris,x = "Species",y= "Sepal.Length",add = "jitter",error.plot = "linerange",add.params = list(color="darkolivegreen2",size=1.5),xlab = 'Treatment',ylab = "Sepal Length",main = mainplotlabel4,ylim = c(0,10),width=1,ggtheme = theme_dark())
setosa.sepal.dotplot + rotate_x_text(45)
解决方法
library(ggpubr)
library(ggtext)
library(tidyverse)
iris %>%
ggerrorplot(
x = "Species",y = "Sepal.Length",add = "jitter",error.plot = "linerange",add.params = list(color = "darkolivegreen2",size = 1.5),xlab = 'Treatment',ylab = "Sepal Length",ylim = c(0,10),width = 1,ggtheme = theme_dark()
) +
labs(
title = "<b>Figure 5</b> <i>Species with long name</i> Long fake name virginica response all things <i>Shorter species</i> Sepal Length Only Purple Long Fake Name") +
theme(
plot.title.position = "plot",plot.title = element_textbox_simple(
size = 13,lineheight = 1,padding = margin(5.5,5.5,5.5),margin = margin(0,0)
)
) +
rotate_x_text(45)
您可以使用<br>
手动在标题中包含换行符。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。