添加分数的一个选项是使用?plotmath
,也就是说,要创建分数,您可以使用label = "frac(1, 9)"
,并在annotate()
中设置parse=TRUE
:
library(ggplot2)
ggplot(mtcars, aes(cyl, mpg)) +
geom_point() +
annotate("text",
x = 5, y = 30, label = "frac(1, 9)", size = 10, color = "red",
parse = TRUE
) +
coord_cartesian()