0

Possible Duplicate:
Combine base and ggplot graphics in R figure window

I'd like to plot side by side a plotrix graphic and a ggplot2 graphic. how could I do ? Below is an unsuccessful attempt (gg1does not appear in the figure).

library(ggplot2)
library(gridExtra)
library(plotrix)

Mvalues <- matrix(rpois(9,1), ncol=3)
Mcolors <- matrix(rpois(9,5), ncol=3)

g1 <- color2D.matplot(x=Mvalues, show.values=2, cellcolors=Mcolors, 
        xlab="x", ylab="y", axes=FALSE, vcex=0.4)
gg1 <- grob(g1) 
gg2 <- ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar(position="dodge") 

grid.arrange(gg1,gg2,ncol=2)
Community
  • 1
  • 1
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225

0 Answers0