R 如何将希腊字母添加到ggplot2中geom_text()标签中的标签
我试图在geom_瓷砖上贴上希腊符号kappa的标签,如下所示 kappa=值 我尝试过使用expression()和bquote(),但找不到使其工作的方法R 如何将希腊字母添加到ggplot2中geom_text()标签中的标签,r,ggplot2,geom-text,R,Ggplot2,Geom Text,我试图在geom_瓷砖上贴上希腊符号kappa的标签,如下所示 kappa=值 我尝试过使用expression()和bquote(),但找不到使其工作的方法 df = data.frame(x = letters[1:10],y = letters[11:20], value = 1:10) p = ggplot(df, aes(x = x, y = y)) + geom_tile()+geom_text(aes(label= paste("k = ",value,"")), color
df = data.frame(x = letters[1:10],y = letters[11:20], value = 1:10)
p = ggplot(df, aes(x = x, y = y)) +
geom_tile()+geom_text(aes(label= paste("k = ",value,"")), color = "white")
p
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/5bDLv.png
使用
parse=TRUE
还可以通过以下内容了解绘图中使用的数学表达式:?plotmath
ggplot(df, aes(x = x, y = y)) +
geom_tile() +
geom_text(mapping = aes(label = paste('kappa', "==", value)), parse = TRUE, color = "white")
您可以尝试使用Unicode转义
粘贴(“\u03f0=”,value)
非常感谢!!kappa的代码是u03ba,但它很有效!!