问题描述
我正在尝试使用bold()
中underline()
中的Grdevices
和paste()
函数来创建一个注释,该注释具有带换行符的风格化,硬编码的“标题”然后是一个可能长达一行或更多行的字符串,并且正在努力实现。 (这是在ShinyApp中完成的,因此我无法对两个相邻的注释进行硬编码,因为字符串中的行数会根据用户的输入而有所不同。)
library(ggplot2)
library(Grdevices)
mydata <- data.frame(Strings = c("This is a list of strings","They Could be \n one line long","Or they Could \n be several lines \n long"),NumberOfLines = c(1,2,3))
rowposition <- sample(1:3,1)
mystring <- mydata$Strings[rowposition]
emptydataframe <- data.frame()
ggplot(emptydataframe) +
geom_blank() +
annotate("text",x = 8,y = -4,label = paste(bold(underline("Title\n")),mystring),size = 3)
非常感谢您的帮助。