> Hi, I'm making a simple population pyramid using two 
> back-to-back bar plots for 18 different age groups with 
> totals for males and females.

I can run both variants without error, though both throw the same warning 
regarding stacking beein 'not well defined ..'

However, the axis scaling in your second variant appears to work if you add a 
limits=(c(-200,200) statement to the y scale, as in

ggplot(data=df,aes(x=df$ag))+geom_bar(subset=.(df$variable=="males"),aes(y=df$value),stat="identity",fill="#330099")+
  
geom_bar(subset=.(df$variable=="females"),aes(y=-df$value),stat="identity",fill="#FF9333")+
  scale_y_continuous(limits=c(-200,200), 
breaks=seq(-200,200,50),labels=abs(seq(-200,200,50)))+
  scale_x_continuous(breaks=seq(1,18,1),labels=abs(seq(1,18,1)))+coord_flip()+
  theme_bw()+xlab("age group")+ylab("population")


I suspect that by specifying the bar values separately from the data supplied 
in the data statement, you've confused ggplot's automatic scaling somewhere. 
But you may have to wait on hadley Wickam's input to find out exactly why.

S Ellison



*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to