title: Combination of stacked and side-by-side bar charts in R
body: <p>In the lattice package of R it is possible to create stacked bar charts. I would like to have several stacked bars side by side similar to this one:</p>
  
  <pre><code>barchart( mpg ~ as.factor(gear), data=mtcars, groups=cyl, stack=F, horizontal=F, auto.key=T )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zkRpJ.png" alt="side-by-side barchart with covered bars"></p>
  
  <p>This is almost what I need. The problem is that the bars are layered, e.g. for the pink bar at the center there are 3 layered bars of approximately the same value (between 17 and 22). The bars are not stacked. The bar that is painted later covers bars painted earlier.</p>
  
  <p>Would it also be possible to have different colors/textures for the stacked bars as well as for the side-by-side bars and an additional legend? The different levels in the stack come from an additional factor. </p>