I'm trying to create some ggplot with overlined axis title. Using a reproducible example, my code is:
library(ggplot2)
library(ggtext)
data("iris")
ggplot(iris, aes(Sepal.Length, Sepal.Width))
geom_point()
xlab("<span style = 'text-decoration: overline;'>Sepal</span> <span style = 'color: #00e000;'>Length</span>")
theme(axis.title.x = element_markdown())
The result, however, doesn't work as expected (overline missing on "Sepal"):
CodePudding user response:
If you don't mind losing the color, you can do it using plotmath
methods:
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width))
geom_point()
xlab(expression(paste(over(,"Sepal"), atop(," Length"))))