title: Layered axes in ggplot?
body: <p>I'm wondering if it's possible to make layered/segmented axes in GGLPOT2 (or another graphics package; I just prefer ggplot). </p>
  
  <p>What I want to do is take the below data, make a stacked bar chart that has Period on the x-axis, but within each period, each animal as well. Then the colors of the bars within each animal will be the 'color' variable</p>
  
  <pre><code>set.seed(1234)
  data &lt;- data.frame(
      animal = sample(c('bear','tiger','lion'), 50, replace=T),
      color = sample(c('black','brown','orange'), 50, replace=T),
      period = sample(c('first','second','third'), 50, replace=T),
      value = sample(1:100, 50, replace=T))
  </code></pre>
  
  <p>then putting this into a stacked bar chart:</p>
  
  <pre><code>library(ggplot2)
  plot &lt;- ggplot(data, aes(x=period, y=value, fill=color)) + 
      geom_bar(stat='identity')
  </code></pre>
  
  <p>Which produces this:</p>
  
  <p><img src="https://i.stack.imgur.com/0B56q.jpg" alt="enter image description here"></p>
  
  <p>But what I really want is, within each bar for period, three separate stacked bars for each animal (stacked by color). </p>
  
  <p>I have a feeling I'm missing a simple piece of syntax here, but the 'obvious' things don't seem to work, eg,</p>
  
  <pre><code>plot &lt;- ggplot(data, aes(x=c(period,animal), y=value, fill=color)) + 
      geom_bar(stat='identity')
  </code></pre>