Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot approximately equal in geom_text

Tags:

r

ggplot2

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.

like image 297
DrDom Avatar asked Dec 11 '12 21:12

DrDom


People also ask

How do I print greater than or equal to in r?

The Less Than or Equal To, and Greater Than or Equal To Operators <= and >= We can also check to see if one R object is greater than or equal to (or less than or equal to) another R object. To do this, we can use the less than sign, or the greater than sign, together with the equals sign.

What does geom_ text do?

Text geoms are useful for labeling plots. They can be used by themselves as scatterplots or in combination with other geoms, for example, for labeling points or for annotating the height of bars. geom_text() adds only text to the plot. geom_label() draws a rectangle behind the text, making it easier to read.


1 Answers

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

like image 165
Sven Hohenstein Avatar answered Oct 16 '22 10:10

Sven Hohenstein