[R] Plot multiple Graphics via Layers

Jim Lemon jim at bitwrit.com.au
Fri Dec 21 03:28:18 CET 2012


On 12/21/2012 04:13 AM, Anne-Marie Brigitte Gallrein wrote:
> 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
>
Hi Anne-Marie,
Your illustration didn't come through, but your code did. My guess is 
that you want to do something like this:

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","magenta",rep("black",2),
          "dodgerblue",rep("black",4)),
         axes=FALSE, width = .5, space = .5)
         axis(side=1, labels=F)}
       )

Jim




More information about the R-help mailing list