3

I'm using ggplot to generate some graphics but get the following error:

Error in FUN(X[[1L]], ...) : could not find function "label.theme"

when trying to specify the label names.

This basic graph gets generated correctly:

p <- ggplot(as.data.frame(list(a=1:5, b=1:5,c=factor(c(1,1,2,2,2)))), aes(x=a,y=b, color=c)) + geom_path(size=1)
p

But this graph produces the above error.

p + opts(legend.text=letters[1:2])

Am I not setting the legend text correctly?

1
  • 1
    The legend.text argument in opts doesn't set the legend text values it alters the legend text formatting. So you'd pass it something like theme_text(size = 3,colour = "blue") to change the size and colour. Commented Jul 13, 2012 at 20:44

1 Answer 1

3

This accomplishes what you want I think:

p + scale_colour_discrete(labels=letters[1:2])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.