我想在图上动态标记轴。标签来自数据框,包含希腊字母以及上级/下级。
在静态情况下,我会知道标签的字母,bquote
会很好地工作。但是在这种情况下,如果标签字符串来自变量,则bquote
会失败。
这展示了我想要实现的目标:
a <- "alpha"
b <- "beta"
ggplot(data.frame(x=c(1),y=c(1)),aes(x,y)) +
geom_point() +
labs(x = bquote(.(a)[.(b)])) + ## will output the greek letters by "name"
labs(y = bquote(alpha[beta])) ## the greek letter-names are replaces by the symbols