title: Plot multiple scatter matrices in one plot
body: <p>I feel like this question has been asked many times before, however from the questions I've looked at, none of the solutions so far have worked for me.</p>
  
  <p>I wish to plot the values of two correlation matrices as scatter plots, next to each other in one plot with the same y range (from 0 - 1).</p>
  
  <p>My original data are time series spanning several years of 112 companies, which I've split into two subsets, period A &amp; period B. The original data is a zoo object.</p>
  
  <p>I have then created the correlation matrices for both periods:</p>
  
  <pre><code>corr_A &lt;- cor(series_A)
  corr_B &lt;- cor(series_B)
  </code></pre>
  
  <p>For further data analysis, I have removed the double entries:</p>
  
  <pre><code>corr_A[lower.tri(corr_A, diag=TRUE)] &lt;- NA
  corr_A &lt;- as.vector(corr_A)
  corr_A &lt;- corr_A[!is.na(corr_A)]
  
  corr_B[lower.tri(corr_B, diag=TRUE)] &lt;- NA
  corr_B &lt;- as.vector(corr_B)
  corr_B &lt;- corr_B[!is.na(corr_B)]
  </code></pre>
  
  <p>As a result, I have two vectors, each with a length of 6216 (111 + 110 + 109 + .. + 1 = 6216).</p>
  
  <p>I have then combined these vectors into a matrix:</p>
  
  <pre><code>correlation &lt;- matrix(c(corr_A, corr_B), nrow=6216)
  colnames(correlation) &lt;- c("period_A", "period_B")
  </code></pre>
  
  <p>I would now like to plot this matrix so the result looks similar to this picture:
  <img src="https://i.stack.imgur.com/nwzTK.png" alt="Two scatter plots in one graph"></p>
  
  <p>I've tried to plot using xyplot from lattice:</p>
  
  <pre><code>xyplot(period_A + period_B ~ X, correlation)
  </code></pre>
  
  <p>However, in the resulting plot, the two scatter plots are stacked over each other:<img src="https://i.stack.imgur.com/arbfK.png" alt="enter image description here"></p>
  
  <p>I have also tried changing the matrix itself - instead of using 6216 rows, I have used 12432 rows, and then index'd the first 6512 rows as "period_A" and the last 6512 rows as "period_B" - the resulting plot looks quite similar to my desired plot:</p>
  
  <p><img src="https://i.stack.imgur.com/qcysj.png" alt="Plot 3"></p>
  
  <p>Is there any way I can create my desired plot using xyplot? Or are there any other (ggplot, car) methods of generating the plot?</p>
  
  <p><strong>Edit (added sample data for reproducible example):</strong></p>
  
  <pre><code>head(correlation) #data frame with 6216 rows, 3 columns
  
  X  period_A period_B
  1    0.5     0.4
  2    0.3     0.6
  3    0.2     0.4
  4    0.6     0.6
  </code></pre>