'How do I plot multiple caterpillar plots in one graph in ggplot?

So I have successfully plotted these graphs individually, now I want to create a plot that has all three categories in one graph with same scales but different colors. Here is my dataset after combining three individual datasets (df_psi, df_gamma and df_eps)

structure(list(label = c("LC5", "LC6", "LC8", "LC9", "LC10", 
"LC11", "LC12", "LC13-17", "bio4", "bio5", "bio12", "bio14", 
"bio15", "NDVI" "bio5", "bio12", "bio14", 
"bio15", "NDVI", "LC5^2", "LC6^2", "LC8^2", "LC9^2", "LC10^2", 
"LC11^2", "LC12^2", "LC13-17^2", "bio4^2", "bio5^20", "bio12^2", 
"bio14^2", "bio15^2","LC9^2", "LC10^2", 
"LC11^2", "LC12^2", "LC13-17^2", "bio4^2", "bio5^20", "bio12^2", 
"bio14^2", "bio15^2", "NDVI^2"), mean = c(-0.02, 0.08, 0.06, 
-0.37, 0.19, 0.17, 0.46, -0.45, -0.1, 0.47, 0.2, -0.51, -0.11, 
0, 0.35, -0.08, 0.22, -0.15, 0.38, 0.39, 
0.24, -0.02, 0.05, 0.03, -0.05, 0.01, -0.07, -0.94, 0.31, -0.06, 
-0.31, 0.05, 0.52,-0.27, -1.22, -0.91
), lower = c(-1.01, -0.86, -0.68, -1.41, -0.4, -0.63, -0.22, 
-1.6, -0.94, -0.33, -0.35, -1.51, -0.89, -0.77, -0.1, -0.03, 
-0.29, -0.92, -0.63, -0.05, -0.42, -0.75, -1.14, -1.05, -0.3, 
-0.64, -0.24, -0.04, -0.89, -1.25, -1.33, -0.87, -0.79, -0.93, 
-0.42, -1.44, -0.45, -0.38, -1.41, -0.66, -0.39, -1.17, -0.1, 
-0.01, -0.7, -0.44, -0.25, -0.6, -0.61, 
-0.56, -0.79, -2.99, -1.82), upper = c(0.96, 1.1, 0.87, 0.42, 
1.03, 1.23, 1.53, 0.31, 0.53, 1.86, 1, 0.14, 0.53, 0.78, 1.51, 
1.86, 0.9, 0.07, 0.47, 1.49, 0.42, 0.06, 0.4, 0.51, 0.46, 0.21, 
0.88, 1.5, 1.47, 1.22, 1.05, 0.83, 1.34, 1.36, 2.19, 0.36, 0.86, 
2.54, 0.13, 0.42, 0.37, 0.16, 1.29, 0.8, 1.32, 0.49, 
0.04, 0.17, 0.02, 0.78, 0.3, -0.06, 0.32, 0.46, 0.08, 0.97, 0.22, 
0.1, -0.11, -0.14), Type = c("psi", "psi", "psi", "psi", "psi", 
"psi", "psi", "gamma", "gamma", "gamma", 
"gamma", "gamma", "gamma", "gamma", "gamma", "gamma", "gamma", 
"gamma", "gamma", "gamma", "gamma", "gamma", "gamma", "gamma", 
"gamma", "gamma", "gamma", "gamma", "gamma", "gamma", "gamma", 
"gamma", "gamma", "gamma", "gamma", "eps", "eps", "eps", "eps", 
"eps", "eps")), row.names = c(NA, 
-84L), class = "data.frame")

I am using similar code to plot individual graphs and now trying to implement it for this new graph with three categories

all_plots  <- ggplot(data=all_posterior, aes(x=label, 
                                             y=mean, 
                                             ymin=lower, 
                                             ymax=upper, 
                                             color = Type)) +
  #geom_pointrange(col = Type) + 
  scale_y_continuous(breaks = seq(-6, 6, 2)) + 
  coord_cartesian(ylim = c(-6, 6)) + 
  theme_bw()  + # use a white background
  ggtitle("CC") +
  theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1, size = 20),
        axis.text.y = element_text(size = 20),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(hjust = 1, size = 20)
  )  

The code is running fine and not giving any errors but the graph windows comes out blank.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source