Skip to content
Back to formatted view

Raw Message

Message-ID: <50D34740.5080100@psychologie.tu-dresden.de>
Date: 2012-12-20T17:13:36Z
From: Anne-Marie Brigitte Gallrein
Subject: Plot multiple Graphics via Layers

Hello,

I want to plot 13 barplots in a 4x4 matrix-window (1st layer).
So that's no Problem, it worked out.

The problem is now, that I want to add two additional layers to this 
graphic.

They contain similar barplots, just with another color for the second 
bar of each barplot (2nd layer) and antoher color for the 5th bar of 
each barplot (3rd layer).
Basically I want to place the 2nd and 3rd pic (attachment) on the first one.

I tried "layers", but it is not really working out. I don't really now 
what to do.

Please find attached the 3 pics and the code I wrote.

Thank very much you for your help,

Anne-Marie Gallrein

-- 
M. Sc. Anne-Marie B. Gallrein
Technische Universit?t Dresden
Institut f?r Klinische, Diagnostische und Differentielle Psychologie
Diagnostik und Intervention
01062 Dresden
Tel. +49 351 463-34004
gallrein at psychologie.tu-dresden.de

-------------- next part --------------
X<-matrix(rnorm(130, sd=.2), ncol=13)

par(mar=c(0,0,0,0))
par(mfrow=c(4,4))

layer1 <- apply(X=X[,1:13],
      MARGIN = 2,
      FUN=function(x) {
        barplot(x, horiz=T, xlim=c(-.75,.75), ylim=c(0,10),col=c("black"), 
                axes=F, width = .5, space = .5)
        axis(side=1, labels=F)}
      )


magenta3 <- c(rep(0,length(X[1,])),X[2,],rep(0,length(X[-(1:2),])))
X2 <- matrix (magenta3, ncol=13, byrow=T)
layer2 <- glayer(apply(X=X2[,1:13],
      MARGIN = 2,
      FUN=function(x) {
        barplot(x, horiz=T, xlim=c(-.75,.75), ylim=c(0,10),col=c("magenta3"), 
                axes=F, width = .5, space = .5)
        axis(side=1, labels=F)}
))


dodgerblue1 <- c(rep(0,length(X[1:4,])),X[5,],rep(0,length(X[-(1:5),])))
X3 <- matrix (dodgerblue1, ncol=13, byrow=T)
layer3 <- glayer(apply(X=X3[,1:13],
      MARGIN = 2,
      FUN=function(x) {
        barplot(x, horiz=T, xlim=c(-.75,.75), ylim=c(0,10),col=c("dodgerblue1"), 
                axes=F, width = .5, space = .5)
        axis(side=1, labels=F)}
))

layer1+layer2+layer3