如果这是一个简单的问题,请原谅我的无知,但是我似乎无法弄清楚如何在情节标题的下划线。我正在使用ggplot2
。
我能找到的最好的方法是手工完成annotate(“ segment”),并且我创建了一个玩具图来说明其方法。
df <- data.frame(x = 1:10, y = 1:10)
rngx <- 0.5 * range(df$x)[2] # store mid-point of plot based on x-axis value
rngy <- 0.5 * range(df$y)[2] # stores mid-point of y-axis for use in ggplot
ggplot(df, aes(x = x, y = y)) +
geom_point() +
ggtitle("Oh how I wish for ..." ) +
ggplot2::annotate("text", x = rngx, y = max(df$y) + 1, label = "underlining!", color = "red") +
# create underline:
ggplot2::annotate("segment", x = rngx-0.8, xend = rngx + 0.8, y= 10.1, yend=10.1)
试试这个:
ggplot(df, aes(x = x, y = y)) + geom_point() +
ggtitle(expression(paste("Oh how I wish for ", underline(underlining))))
另外,正如BondedDust在评论中指出的那样,您可以paste()
完全避免调用,但要注意for
:
ggplot(df, aes(x = x, y = y)) + geom_point() +
ggtitle(expression(Oh~how~I~wish~'for'~underline(underlining)))
或巴蒂斯特提出了另一个,甚至更短的方法不使用expression
,paste()
或波浪线很多:
ggplot(df, aes(x = x, y = y)) + geom_point() +
ggtitle(~"Oh how I wish for "*underline(underlining))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句