0

To separate two groups of bar plot, I followed the method by How to control space between stack bars in ggplot2? The main idea is making a dummy raw but shows NA label on x-axis. The code I'm using:

Df %>% 
  bind_rows(data_frame(var1 = "trt99")) %>% 
  ggplot(aes(x=var1, y=value*100, fill = var3)) +

  geom_bar(stat='identity', width=0.3,
       position = position_dodge(width=1))+

  scale_x_discrete(expand=c(0.05,0),
                limits = c("Rho(-)", "Rho(+)", "trt99", "Artemia", "Aca(-)", "Aca(+)"),
                breaks = c("Rho(-)", "Rho(+)",    NA  , "Artemia", "Aca(-)", "Aca(+)"),
                labels = c("Rho(-)", "Rho(+)",     " ", "Artemia", "Aca(-)", "Aca(+)"))+

  theme(panel.border = element_blank(),
          legend.position = c(0.2,0.9))

And I get the figure like: enter image description here

My question is: How can I remove the NA legend key from this plot?

Jellz
  • 435
  • 1
  • 7
  • 14

0 Answers0