title: Dual plot sharing the same x-axis in ggplot2
body: <p>I have a dataset in this format.</p>
  
  <pre><code>head(sppec.p)
      Wavelength_.nm.      Mean     Lower     Upper Species Feature_selection Count
  1             400 0.1467549 0.1290778 0.2758327    ALAL            T-test     0
  2             405 0.1454303 0.1271905 0.2726207    ALAL            T-test     0
  3             410 0.1464431 0.1290472 0.2754903    ALAL            T-test     0
  4             415 0.1468586 0.1298166 0.2766753    ALAL            T-test     0
  5             420 0.1485061 0.1310419 0.2795480    ALAL            T-test     0
  6             425 0.1517019 0.1342690 0.2859708    ALAL            T-test     0
  </code></pre>
  
  <p>I originally planned on doing a dual-axis graph, but after searching here, I realized that it was "not possible" in <code>ggplot</code> and many advised against such plots. Therefore I have settled for a facet plot. I tried to do the individual plots first but I cannot figure out how to use <code>facet_wrap</code> and <code>scales = "free_y"</code> to get the 2 plots of identical x-axis but different y-axis. </p>
  
  <p>Code for the individual graphs:</p>
  
  <pre><code>  myplot&lt;-ggplot(sppec.p, aes(x=Wavelength_.nm., y=Mean, group=Species, linetype =   Species,
  ymin = Lower, ymax =  Upper)) +
   geom_ribbon(alpha = 0.2,fill='gray') +
   geom_line() +  theme_bw() +scale_fill_grey(start = 0.1, end = 0.9) +
   opts(panel.background = theme_rect(fill='grey80')) +
   ylim(0,3)
  
  myplot + theme_bw ()+ opts(axis.line = theme_segment(colour = "black"),
    panel.grid.major = theme_blank(),
    panel.grid.minor = theme_blank()) 
  </code></pre>
  
  <p>...which produces
  <img src="https://i.stack.imgur.com/wVesj.png" alt="enter image description here"></p>
  
  <p>And the second graph:</p>
  
  <pre><code>  cum.totals&lt;-ggplot(sppec.p, aes(Wavelength_.nm., y=Count, fill =     factor(Feature_selection))) + geom_bar(stat="identity")
     cum.totals + theme_bw() +scale_fill_grey(start = 0.1, end = 0.9)+
  opts(axis.line = theme_segment(colour = "black"),
  panel.grid.major = theme_blank(),  
  panel.grid.minor = theme_blank(),
  panel.border = theme_blank(),
  panel.background = theme_blank())
  </code></pre>
  
  <p>Graph produced:</p>
  
  <p><img src="https://i.stack.imgur.com/6UkkL.png" alt="enter image description here"></p>
  
  <p>Though both y-axis appear numerically equivalent, they represent different values.</p>
  
  <p>I am not very familiar with <code>ggplot</code> and I would like to know how to use <code>facet_wrap</code> or any other function that would give me the 2 plots on the sharing the same a-axis but in 2 facets. Is it possible to make my code more efficient? </p>
  
  <p>So essentially the layout of the final output would be something like this:
  <img src="https://i.stack.imgur.com/OC0SB.png" alt="enter image description here"></p>