I tried to add subscripts to my ggplot2 geom_point colour legend by using scale_colour_discrete
. Similar problems popped up here
p <- ggplot(myData, aes(myFeature1,myFeature2))
p <- p + geom_point(aes(colour = myFeature3)) + facet_grid(n ~ cond)
p <- p + scale_colour_discrete(breaks = levels(myData$myFeature3), labels = c(expression(myFeature3[1]),expression(myFeature3[2]))
However, the following error occurs: Error in FUN(X[[1L]], ...) : cannot coerce type 'symbol' to vector of type 'double'
This error does NOT occur, without in the labels
definition expression
. It DOES occur whatever is inside the expression
.
Any ideas on the subject? Does scale_colour_discrete
just not work with expression
? Is there another way to get subscripts into those legend factor names?
Thanks a lot!