Jeff Allen
Jeff Allen

Reputation: 17517

ggplot with custom legend.text

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?

Upvotes: 3

Views: 1258

Answers (1)

bdemarest
bdemarest

Reputation: 14667

This accomplishes what you want I think:

p + scale_colour_discrete(labels=letters[1:2])

Upvotes: 3

Related Questions