title: facet_wrap: omit unneeded x-entries
body: <p>I have a plot with <code>facet_wrap</code> where some combinations of my x-axis and the faceting variable are not present in the data set.</p>
  <p>I would like to omit these completely in the plot but cannot find a way of doing so.</p>
  <p>Consider this example:</p>
  <pre><code>ggplot(mpg %&gt;% filter(displ&gt;3, trans %in% c(&quot;auto(l5)&quot;, &quot;manual(m5)&quot;), cty&lt;15) %&gt;% mutate(displ=as.integer(displ), displ_char=case_when(displ==3~&quot;a_three&quot;, displ==4~&quot;b_four&quot;, displ==5~&quot;c_five&quot;, displ==6~&quot;d_six&quot;)), 
     aes(x=displ_char, y=cty)) + geom_boxplot() + facet_wrap(vars(trans), nrow = 1)
  </code></pre>
  <p>This produces the following plot:</p>
  <p><a href="https://i.stack.imgur.com/RO273.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RO273.png" alt="plot_output" /></a></p>
  <p>Note, however, that e.g. <code>auto(l5)</code> has no <code>displ_char</code> values of <code>a_three</code> (likewise for <code>manual(m5)</code> and <code>d_six</code>. I would like to remove those. The desired output looks like this (produced with image editing):</p>
  <p><a href="https://i.stack.imgur.com/kPpRA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kPpRA.png" alt="desired_output" /></a></p>
  <p>This could be achieved by (on-the-fly) data manipulation or plotting options, but only factor levels that are actually present should be plotted on the x-axis.</p>