Skip to content

ggplot2: expression() in legend labels?

3 messages · Hadley Wickham, Casper Ti. Vector, Dennis Murphy

#
You need to set the labels...

Hadley

On Sat, Sep 24, 2011 at 3:49 AM, Casper Ti. Vector
<caspervector at gmail.com> wrote:

  
    
#
Hmm, that's my fault when composing this mail, but the problem was
really encountered at that time.
Nevertheless, neither can I reproduce the problem now, perhaps I just
made another mistake at that time.
Thanks all the same, and sorry for the disturbance anyway :|
On Tue, Oct 04, 2011 at 10:10:56AM -0500, Hadley Wickham wrote:

  
    
#
Hi:

Here's a reproducible example:

d <- data.frame(grp = factor(rep(c('x', 'y'), each = 5)),
                 ev = rnorm(10), dv = rnorm(10))
labl <- list(expression(italic('x')), expression(italic('y')))

ggplot(d, aes(x = ev, y = dv, shape = grp)) + geom_point() +
   scale_shape_manual('Group', breaks = levels(d$grp),
                               values = 1:2,
                               labels = labl)

HTH,
Dennis

On Tue, Oct 4, 2011 at 8:59 AM, Casper Ti. Vector
<caspervector at gmail.com> wrote: