Finetuning a forest plot with ggplot2

Viewed 10928

I am trying to make a forest plot in R, displaying results from a meta-analysis. However, I run into problems using ggplot2. I have not found similar questions on stackoverflow so far and would really appreciate some help.

The code I am using now looks like this (I changed it a bit to make it self-containing):

cohort <- letters[1:15]
population <- c(  runif(15, min=2000, max=50000)) #hit1$N
beta <-  c(  runif(15, min=-1, max=2))
lower95 <- c(runif(15, min=-1.5, max=0.5))
upper95 <- c(runif(15, min=1.5, max=2.5))
type <- c("CBCL","SDQ","CBCL","SDQ","CBCL","SDQ","CBCL")
data <- as.data.frame(cbind(cohort, population, beta ,lower95,upper95,type))


ggplot(data=data, aes(x=cohort, y=beta))+
  geom_errorbar(aes(ymin=lower95, ymax=upper95), width=.667) +
  geom_point(aes(size=population, fill=type), colour="black",shape=21)+
  geom_hline(yintercept=0, linetype="dashed")+
  scale_x_discrete(name="Cohort")+
  coord_flip()+
  scale_shape(solid=FALSE)+
  scale_fill_manual(values=c( "CBCL"="white", "SDQ"="black"))+
  labs(title="Forest Plot") +
  theme_bw()

Now, I have the following issues:

  • The x-axis is unreadable because all the values are overlapping.
  • The legend to the right ('population') displays all the values, but I want it solely to display some arbitrary values, like 5000, 10000 and 15000.
  • The plot should have a dashed line at y=0, but this line is displayed to the far right of the plot, which can't be right.
  • I would like to add additional text columns to the right of each bar (to display additional info for each specific cohort).
  • Any modifications to make the plot 'prettier' is always welcome.

Thanks in advance!

1 Answers
Related