Dear colleagues,
I am trying to plot a long data frame, population_proj_2012_race_age_groups using ggplot(). Here is the code:
population_proj_2012_race_age_groups$variable <- as.factor(population_proj_2012_race_age_groups$variable)
ggplot(data=population_proj_2012_race_age_groups,aes(x=YEAR, y=value,color=variable))+
geom_line()+
labs(title="Variation of Population for Age Groups Across Races",y="Population(in percent)")+
facet_wrap(~RACE)+
theme(axis.text.x=element_text(angle=45))+
scale_y_continuous( limits=c(0, 50))
As seen, I am trying to get the colour corresponding to the values of variable. But when I look at the output, one of the lines corresponding to teenagers_percent is missing. The strange thing is that we can see it in legends on the right-hand side, but the line is missing. Moreover, I checked the values for data, it is greater than 0 throughout. Can I kindly et some feedback why is this glitch occurring? thanks