title: Create space and a vertical line between categories using geom_bar plot in ggplot2 in R
body: <p>I have a bar chart in R using ggplot2 that shows different bars of different categories. Because some bar are = 0, I want to make a vertical line between the different categories so that they can be distinguished better visually.</p>
  
  <p>I have already tried adding it through the <code>panel.grid.major.x</code>  and <code>panel.grid.minor.x</code> arguments but that did not work.  It would maybe also help if I can change the distance between the bars of the differnet categories instead of all of them when I do so with the  <code>width</code> argument of <code>geom_bar</code> </p>
  
  <p>Eg. in figure below: I want to add a vertical line and space between the purple bar of Cat 3 (Class 5) and the blue bar (Class 1) of Cat 4.</p>
  
  <p><a href="https://i.stack.imgur.com/2CPUT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2CPUT.png" alt="Example plot"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>data &lt;- categories.df
  ggplot(data, aes(factor(Name, levels = c("Cat 1", "Cat 2", "Cat 3", "Cat 4", "Cat 5")), Count, fill = factor(SC_Class, levels = c("Class 1", "Class 2", "Class 3", "Class 4", "Class 5")))) +
      geom_bar(stat = "identity", position = position_dodge(width = 1), width = 0.8) +
      scale_fill_manual(values = c("#6C8EBF", "red", "#74767a", "orange","purple")) +
      labs(fill = "") +
      ylim(0,25) +
      xlab("Category") + ylab("Count") +
      theme(legend.position = c(1,1), legend.justification = c(1,1),
            axis.text.x = element_text(face = "bold", size=14),
            axis.text.y = element_text(face = "bold", size=14),
            axis.title.x = element_text(colour = "#6C8EBF", face = "bold", size =16),
            axis.title.y = element_text(colour = "#6C8EBF", face = "bold", size =16),
            panel.grid.major.y = element_line(size = 1, colour="#DAE8FC"),
            panel.grid.minor.y = element_line(colour="#DAE8FC"),
            panel.grid.major.x = element_blank(),
            panel.grid.minor.x = element_line(size = 1, colour="#DAE8FC"),
            plot.background = element_blank(),
            panel.background = element_blank(),
            panel.border = element_blank(),
            legend.text = element_text(size=12, face="bold")) 
  </code></pre>
  
  <p><strong>How can I add a vertical line and spaces between the different categories using ggplot2 in R?</strong></p>