title: How do I plot charts with nested categories axes?
body: <p>I'm plotting data which have both a category and a sub-category (see the example data below) and I'd like to display these with them nested (this example was created in Excel):</p>
  
  <p><img src="https://i.stack.imgur.com/famZp.png" alt="Nested categories from Excel"><br>
  The best I've come up with in R is to create a new column with the desired names, like this:</p>
  
  <pre><code>df &lt;- data.frame(main.cat = c("A", "A", "B", "B", "B", "C"),
                   second.cat = c("a1", "a2", "b1", "b2", "b3", "c1"),
                   value = c(2, 3, 4, 2.5, 1.5, 2.3))
  
  df$x.labels &lt;- paste(df$second.cat, df$main.cat, sep = "\n")
  
  ggplot(data = df, aes(x = x.labels, y = value)) + geom_point()
  </code></pre>
  
  <p>This at least retains both levels of categories, but duplicates all of the main category labels:
  <img src="https://i.stack.imgur.com/eFtoC.png" alt="enter image description here">  </p>
  
  <p>Does anyone know of anything better, which would look more like Excel's output?</p>