add plotmath text

79 views
Skip to first unread message

d.c.c...@its.leeds.ac.uk

unread,
May 8, 2009, 4:26:13 AM5/8/09
to ggplot2
Dear all,

I want to add some annotations to a plot that include plotmath-type
expressions. I can't seem to get this to work.

## make some data
mydata <- data.frame(x = 1:10, y = 1:10)

## plain text works
ggplot(mydata, aes(x, y)) +
geom_point() +
annotate("text", x = 6, y = 7, label = "some text")

## this does not
ggplot(mydata, aes(x, y)) +
geom_point() +
annotate("text", x = 6, y = 7, label = expression(beta[1] == 1))

Error in as.character(x$label) :
cannot coerce type 'closure' to vector of type 'character'

Am I doing something wrong, or is this a problem?

Thanks

David

hadley wickham

unread,
May 8, 2009, 1:36:19 PM5/8/09
to d.c.c...@its.leeds.ac.uk, ggplot2
Hi David,

It's not currently possible to do this, but it is a good idea. I'll
add it to my to do list.

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages