7

in advance I am sorry if I am bothering you with trivial questions.

I should made 1 figure which contains 4 different correlation pairwise plots. The look of wanted graph can be seen as follows: enter image description here

Every single pairwise plot I am making with function pairs():

pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency=1 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 2 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 5 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 10 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)

When I combine above pairwise plots through usage of layout function, it is not working (as far as I understood from similar questions layout() and pairs() cannot be combined).

If anyone has an elegant way to combine 4 different correlation pairwise plots, the help would be greatly appreciated.

Robin Hood
  • 259
  • 5
  • 15

3 Answers3

1

Update, 12014-07-31 11:48:35Z

As ilir pointed out below pairs somehow overwrites par, most likely for some good reason.

@user44037, can you solve your problem working form this code snippet? Copy/pasted from here. I believe the solution can be found using splom from lattice. take a look at ?splom.

 library(lattice) 
 splom(~iris[1:3]|Species, data = iris, 
      layout=c(2,2), pscales = 0,
      varnames = c("Sepal\nLength", "Sepal\nWidth", "Petal\nLength"),
      page = function(...) {
          ltext(x = seq(.6, .8, len = 4), 
                y = seq(.9, .6, len = 4), 
                lab = c("@user44037,", "can you solve your", "problem working form ", "this code snippet?"),
                cex = 1)
      })

enter image description here

Initial answer, 12014-07-31 11:35:33Z

Simply following Avinash directions by copy/pasting code from the website Quick-R. Feel free to improve on this example.

I'm happy to troubleshoot your specific problem if you provide a reproducible example.

# 4 figures arranged in 2 rows and 2 columns
attach(mtcars)
par(mfrow=c(2,2))
plot(wt,mpg, main="Scatterplot of wt vs. mpg")
plot(wt,disp, main="Scatterplot of wt vs disp")
hist(wt, main="Histogram of wt")
boxplot(wt, main="Boxplot of wt")

enter image description here

Eric Fail
  • 8,191
  • 8
  • 72
  • 128
  • 2
    Try that with `pairs(iris)` and you will see it does not work. – ilir Jul 31 '14 at 11:36
  • Eric Fail, thank you for splom code. Unfortunately, I do not know how to run it on my data. I have 24 time series, belonging to 4 independent groups (4 Pirwise correlation plots): Frequency = 1 Min. , with belonging time series AAPL_1m,MSFT_1m,INTC_1m,FB_1m,MU_1m,IBM_1m. Frequency = 2 Min. , with belonging time series AAPL_2m,MSFT_2m,INTC_2m,FB_2m,MU_2m,IBM_2m.Frequency = 5 Min. , with belonging time series AAPL_5m,MSFT_5m,INTC_5m,FB_5m,MU_5m,IBM_5m. Frequency = 10 Min. , with belonging time series AAPL_10m,MSFT_10m,INTC_10m,FB_10m,MU_10m,IBM_10m. Each pairwise plot should show correlation – Robin Hood Aug 01 '14 at 08:11
  • I also shared a new question regarding the application of splom() function in combination of 4 pairwise plots (http://stackoverflow.com/questions/25076293/how-to-apply-splom-function-in-order-to-create-multiple-correlation-pairwise-p) – Robin Hood Aug 01 '14 at 08:51
  • It would be helpful if you could provide us with a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). That way we can be much more focused when we try to help you. We avoid wasting your time and you avoid wasting our time. – Eric Fail Aug 01 '14 at 08:57
  • Also, now that you have posted a new question, I think you should decide if this question is answered or where you want to take it from here. – Eric Fail Aug 01 '14 at 08:58
1

The problem is solved by using of splom() function as Eric Fail suggested:

The solution can be found here.

Community
  • 1
  • 1
Robin Hood
  • 259
  • 5
  • 15
0

The answer to this question might help: Create a matrix of scatterplots (pairs() equivalent) in ggplot2

you could create the pairs plots using ggpairs in the GGgalley package. Since these should then be ggplot objects you could arrange them using grid.arrange in the gridExtra package.

Community
  • 1
  • 1
Chris
  • 418
  • 3
  • 10
  • Unfortunately, this does not appear to work. A longer description why not is at: http://stackoverflow.com/questions/24135157/arranging-ggally-plots-with-gridextra. –  Jul 31 '14 at 12:28