How do I color two data series different colors on the same plot?
I combined two different dataframes:
ages_test=c('<18','18-24','25-44','45-64','65+',"UNKNOWN")
values_test=c(411694,1313082,2301521,918416,41728,178)
df_test1=data.frame(ages_test,values_test)
values_test=c(134924,350794,612476,228237,10472,49)
df_test2=data.frame(ages_test,values_test)
df_combined = rbind(df_test1, df_test2)
Then I created this plot:
df_combined %>%
ggplot(aes(x=ages_test, y=values_test), label=values_test) +
geom_bar(stat='identity') +
scale_y_continuous(breaks=scales::breaks_extended(n=10), labels=comma) +
geom_text(hjust=.5, vjust=-1, size=3, aes(label=comma(values_test)))
This chart contains the two different data series and labels for each. I want one of them to be a different color so that I can differentiate between the two.
I tried adding fill=values_test to aes like so ggplot(aes(x=ages_test, y=values_test, label=values_test, fill=values_test)) but the resulting chart shows a color gradient:
However, I want only two different colors, one for each data series.
I've also tried using color=as.factor(values_test) but this yields 12 different colors, one for each age category in my combined dataframe.



