If you want to use the Brewer Set1 with this set of groups, you can do something like this:
library(ggplot2) count_group <- data.frame(user=factor(rep(1:50, 2)), count=sample(100, 100, replace=T), group=factor(rep(LETTERS[1:20], 5))) library(RColorBrewer) cols <- colorRampPalette(brewer.pal(9, "Set1")) ngroups <- length(unique(count_group$group)) qplot(user, count, data=count_group, geom="histogram", fill=group, xlab = "users", ylab="count") + opts(axis.text.x=theme_text(angle=90, hjust=0, size=7)) + scale_fill_manual(values = cols(ngroups))

EDITYou can create and use multiple colorRampPalette s, for example. To assign blues to groups AJ and red for groups K to T:
blues <- colorRampPalette(c('dark blue', 'light blue')) reds <- colorRampPalette(c('pink', 'dark red')) qplot(user, count, data=count_group, geom="histogram", fill=group, xlab = "users", ylab="count") + opts(axis.text.x=theme_text(angle=90, hjust=0, size=7)) + scale_fill_manual(values = c(blues(10), reds(10)))

source share