title: stacking plots with R
body: <p>I'm fairly new to R and I'm trying to stack three plots over each other to study the diversity of each plot from one another. Being a newbie to R I still haven't managed to find a solution. I've tried the ggplot and multiplot but failed to accomplish the task. Maybe the header in my text file is the problem or I'm not even seeing the problem clearly! It'd be of great help if anyone can advise me in this regard.. </p>
  
  <p>My script is as follow: </p>
  
  <pre><code>defects &lt;- read.table(file="C:/_____.txt",header=TRUE)
  squareX &lt;- c()        
  squareY &lt;- c()        
  
  distance &lt;- c(0, 17.0, 17.5, 34.5, 35.0, 52.0, 52.5, 69.5, 70.0, 87.0,
                87.5, 104.5, 105.0, 122.0, 122.5, 139.5)
  square_beginning &lt;- distance[seq(1,length(distance),2)] 
  
  for ( i in 1:length(defects$x)){ 
  
    for (e in square_beginning){
      if (defects$x[i]&gt;e &amp; defects$x[i]&lt;e+17.5) {
        squareX[i] &lt;- e/17.5+1 
      }
      if (defects$y[i]&gt;e &amp; defects$y[i]&lt;e+17.5) {
        squareY[i] &lt;- e/17.5+1
      }
    }
  }
  
  defects&lt;- cbind(defects,squareX,squareY)
  #plot (defects)
  
  cont &lt;- read.table(file="C:/____.txt",header=TRUE)
  squareX &lt;- c()         
  squareY &lt;- c()         
  
  distance &lt;- c(0, 17.0, 17.5, 34.5, 35.0, 52.0, 52.5, 69.5, 70.0, 87.0,
                87.5, 104.5, 105.0, 122.0, 122.5, 139.5)
  square_beginning &lt;- distance[seq(1,length(distance),2)] 
  
  for ( i in 1:length(cont$x)){ 
  
    for (e in square_beginning){  
      if (cont$x[i]&gt;e &amp; cont$x[i]&lt;e+17.5) {
        squareX[i] &lt;- e/17.5+1 
      }
      if (cont$y[i]&gt;e &amp; cont$y[i]&lt;e+17.5) {
        squareY[i] &lt;- e/17.5+1
      }
    }
  }
  par(mo=c(1,2))
  plot(defects, main="test 1")
  plot(cont, main="test 2")
  </code></pre>