title: Axis labels for two variables in ggplot?
body: <p>I have a ggplot with three variables: office, level, and gender. The plot should be factored by office and level and shows the levels and gender representation for each office. I have no problem faceting the plot the way I want, but I haven't been able to create x axis text to show the levels in each office -- all that shows up under the x-axis are the office names, which makes it impossible to distinguish among the bars for the different levels (the gender I handle with different colors and isn't a problem, unless someone is colorblind ...). I've edited out the lines for the title, xLab, yLab, etc. to focus on the issue. Grateful for your help!</p>
  <p>Here is my data:</p>
  <pre><code>#A tibble: 20 x 4
  
     office     level   gender     count
   1 office1      A     Female     3
   2 office1      A     Male       1
   3 office1      B     Female     11
   4 office1      B     Male       9
   5 office1      C     Female     16
   6 office1      C     Male       13
   7 office1      C     Other      2
   8 office1      D     Female     16
   9 office1      D     Male       11
  10 office1      D     Female     6
  11 office1      D     Male       10
  12 office1      D     Other      1
  13 office2      A     Male       1
  14 office2      A     Female     3
  15 office2      B     Male       1
  16 office2      B     Female     12
  17 office2      B     Male       3
  18 office2      B     Female     1
  19 office2      D     Male       5
  20 office2      D     Male       1
  </code></pre>
  <p>And here is my code:</p>
  <pre><code>myBarChart &lt;- function(data,var1,var2,var3,count,factor1, factor2) {
    
  # the following code creates the tibble above when I run the function:
    fields &lt;- c(var1,var2,var3)
    data &lt;- df[ ,fields]
    data[[var1]] &lt;- factor(data[[var1]], levels = factor1)
    data[[var2]] &lt;- factor(data[[var2]], levels = factor2)
    data &lt;- data %&gt;% group_by_at(fields) %&gt;% summarize(count = n()) 
    data &lt;- filter(data,count &gt;= 1)
    data &lt;- na.omit(data) %&gt;% 
  
  # here is the plot code and this is where I need help: 
    ggplot(data, aes_string(x=var1, y=count, fill=var3)) +
      geom_bar(stat = 'identity',width=1.25,position = position_dodge2(padding=0.25,reverse=FALSE,preserve=c(&quot;single&quot;))) +
      geom_text(aes(label=count),vjust=-.5,position=position_dodge2(width=1.25,preserve=&quot;single&quot;),size=2.5) +
      facet_wrap(var1, strip.position=&quot;bottom&quot;, scales = &quot;free_x&quot;, nrow=1)  +
  
  # I was hoping that the code for strip.text.x would give me the values for var2 (the levels) within each office, but it doesn't.
      theme(strip.text.x = element_text(aes(label=data[[var2]]), size=12)) + 
      theme(strip.placement = &quot;outside&quot;)
  
  } # end function
  
  # here is how I invoke the function, which runs fine except for the axis labels always reflecting only 'office': 
       myBarChart(data,'office','level','gender',c('office1','office2'),c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;),'count')
  </code></pre>