title: Fill and dodge boxplots by group on a continuous x axis
body: <p>I have been having issues with what seems to be a simple thing to do: grouped boxplots with a continuous x axis.</p>
  
  <p>Here is come minimal data data:</p>
  
  <pre><code>df &lt;- cbind(expand.grid(x=1:10, rep=1:20, fill=c("A", "B")), y=runif(400))
  </code></pre>
  
  <p>And here is what I want;  you will see I have forced the x axis to be discrete:</p>
  
  <pre><code>ggplot(df, aes(x=as.factor(x), y=y,  fill=fill)) + geom_boxplot()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RSNFl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RSNFl.png" alt="enter image description here"></a></p>
  
  <p>This is what I get when I leave <code>x</code> as continuous, without a grouping:</p>
  
  <pre><code>ggplot(df, aes(x=x, y=y,  fill=fill)) + geom_boxplot()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/s3ncD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/s3ncD.png" alt="enter image description here"></a></p>
  
  <p>When I add a grouping, the color disappears:</p>
  
  <pre><code> ggplot(df, aes(x=x, y=y, group=x, fill=fill)) + geom_boxplot()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/goi55.png" rel="noreferrer"><img src="https://i.stack.imgur.com/goi55.png" alt="enter image description here"></a></p>
  
  <p>To be clear, what I would want in <code>geom_point</code> would be:</p>
  
  <pre><code>ggplot(df, aes(x=x, y=y, group=x, color=fill)) + geom_point(position=position_dodge(width=.7))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7Scy5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7Scy5.png" alt="enter image description here"></a></p>
  
  <p>...but if I try to set a dodge in boxplot:</p>
  
  <p>ggplot(df, aes(x=x, y=y,  color=fill)) + geom_boxplot(position=position_dodge(width=.7))</p>
  
  <p><a href="https://i.stack.imgur.com/zGEh2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zGEh2.png" alt="enter image description here"></a></p>
  
  <p>Any tips?  I have tried searching around: <a href="https://stackoverflow.com/questions/27050802/how-to-create-geom-boxplot-with-large-amount-of-continuous-x-variables">this question</a> addressed continuous boxplots, but without the coloring issue; <a href="https://stackoverflow.com/questions/31999185/ggplot-multi-factor-level-grouping-for-boxplot-with-continuous-scale">this question</a> makes me wonder if i need to set an interaction, but doesn't seem to get the desired results.  Any help would be hugely appreciated!</p>