Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在标题中斜体和插入换行符_R_Ggplot2 - Fatal编程技术网

R 在标题中斜体和插入换行符

R 在标题中斜体和插入换行符,r,ggplot2,R,Ggplot2,我试图在我的情节标题中的一个单词斜体化后创建一个换行符 以下是在ggplot2中创建标题的标准代码,该代码有效: labs(title = "Species\n next line", y = "Y axis", x = "X axis") 一旦我把它定制成斜体。。。断线消失了 labs(title = expression (paste (italic("species"), "subspecies \n new line")) 如何保持尝试插入的换行符 您是否有兴

我试图在我的情节标题中的一个单词斜体化后创建一个换行符

以下是在ggplot2中创建标题的标准代码,该代码有效:

labs(title = "Species\n next line", 
     y = "Y axis", 
     x = "X axis")
一旦我把它定制成斜体。。。断线消失了

labs(title = expression (paste (italic("species"), "subspecies \n new line"))

如何保持尝试插入的换行符

您是否有兴趣使用
字幕

library(ggplot2)

ggplot(iris[iris$Species == "setosa", ], aes(x = Sepal.Width, y = Sepal.Length)) +
  theme_bw() +
  labs(title = substitute(paste(italic("Iris"), setosa)), subtitle = "new line") +
  # labs(title = expression(italic("Iris")~"setosa"), subtitle = "new line") +
  geom_smooth(method = "lm", se = FALSE) +
  geom_point(shape = 1, size = 2)

要向标题添加粗体字体,可以使用
bold()


你是如何将斜体字加粗的?我认为加粗的物种名称之所以出现,是因为名称的大小比副标题大。请参阅我的编辑,了解如何使字体真正粗体。
ggplot(iris[iris$Species == "setosa", ], aes(x = Sepal.Width, y = Sepal.Length)) +
  theme_bw() +
  ggtitle(label = expression(italic("Iris")~bold("setosa")), subtitle = "new line") +
  theme(plot.title = element_text(face = "plain")) +
  geom_smooth(method = "lm", se = FALSE) +
  geom_point(shape = 1, size = 2)