I'm working of from a return ggplot object and want to override the legend labels. I tried overriding with guides but it does not seem to work. Any way else to do this?
library ( ggplot2 )
make_plot <- function (){
g1 = ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) +
geom_bar( ) +
scale_fill_brewer(palette = "Set1")
return ( g1 )
}
g1 = make_plot()
g1 + guides( fill = guide_legend(title.position="top" , title ="Groups", labels=c("c","b", "c") ) )
so what I want here is to have the legend labels changed to a b c instead of 4,5, 6