Dear all,
I am looking for a solution how to plot a tornado diagram with Y axis centered at the middle of X axis (to craete a population age pyramid)
this is my syntax for the descrbed problem with the y axis at the left of the diagram.
dat <- data.frame(
variable=c("00-04","05-09","10-14","15-19","20-24","25-29","30-34","35-39","40-44","45-49","50-54","55-59","60-64",
"65-69","70-74","75-79","80-84","85+","00-04","05-09","10-14","15-19","20-24","25-29","30-34","35-39","40-44"
,"45-49","50-54","55-59","60-64","65-69","70-74","75-79","80-84","85+"),
Level=c("Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Male","Male",
"Male","Male","Male","Female","Female","Female","Female","Female","Female","Female","Female","Female",
"Female","Female","Female","Female","Female","Female","Female","Female","Female"),
value=c(4.3,4.5,5.0,5.2,6.3,6.3,6.2,6.0,8.1,9.1,8.1,6.9,6.0,4.8,5.8,3.7,2.3,1.4,
- 4.0,- 4.1,- 4.6,- 4.8,- 5.8,- 5.9,- 5.9,- 5.7,- 7.5,- 8.4,- 7.6,- 6.7,- 6.0,- 5.0,- 6.4,- 4.7,- 3.5,- 3.5)
)
library(ggplot2)
ggplot(dat, aes(variable, value, fill=Level)) + geom_bar(position="identity")
p<-ggplot(dat, aes(variable, value, fill=Level)) + geom_bar(position="identity")
p
p+coord_flip()+ ylab("Percentage") + xlab("Age")
Does anyone have an idea to fix the y axis at the middel of the x axis?
Thank you very much, ulrike