Plot approximately equal in geom_text

2019-06-17 04:18发布

I cannot realize how to put approximately equal symbol before the text inserted with geom_text. This works:

ggplot(data.frame(x=1:2, y=1:2), aes(x=x,y=y)) + geom_point() +
  geom_text(aes(label="10^10", x=1.5, y=1.5), parse=T)

If I put %~~% before the text

ggplot(data.frame(x=1:2, y=1:2), aes(x=x,y=y)) + geom_point() +
  geom_text(aes(label="%~~%10^10", x=1.5, y=1.5), parse=T)

it returns an error: unexpected SPECIAL %~~%

I found several related questions but could not apply the given advices. I use package ggplot2_0.9.2.1. Package grDevices is also loaded.

标签: r ggplot2
1条回答
我命由我不由天
2楼-- · 2019-06-17 04:58

It will work with something on the left-hand site of the equation. This could also be NULL.

ggplot(data.frame(x=1:2, y=1:2), aes(x=x,y=y)) + geom_point() +
   geom_text(aes(label="NULL%~~%10^10", x=1.5, y=1.5), parse=T)

enter image description here

查看更多
登录 后发表回答