如何在ggplot2的geom_text()标签中向标签添加希腊字母

时间:2020-04-02 21:45:16

标签: r ggplot2 geom-text

我正在尝试用希腊符号kappa在geom_tile中标记瓷砖,如下所示

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 = "white")

p

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/5bDLv.png

1 个答案:

答案 0 :(得分:3)

使用]

还可以通过以下方式进一步了解绘图中使用的数学表达式:parse = TRUE

?plotmath

enter image description here