0

How do you combine two ggplots g1 and g2 with one on the left and one on the right, 90° rotated (only the right one) ?

I have already looked at grid and gridExtra package but I don't find my way through all of this.

Axeman
  • 32,068
  • 8
  • 81
  • 94
Rodolphe LAMPE
  • 1,346
  • 2
  • 11
  • 17
  • 2
    It's helpful to provide a minimal [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can test possible solutions. Show what code you tried and describe exactly where you were getting stuck. If you've already worked on this no reason to make is start from scratch. – MrFlick Sep 26 '16 at 21:41
  • 1
    Use coord_flip() on the right handside plot, then use gridExtra or cowplot package to put plots side by side. – zx8754 Sep 26 '16 at 21:43

1 Answers1

1

Some adjustments might be necessary for the width and height of the second plot, but this seems to work:

p <- qplot(1:10)

library(grid)
grid.newpage()
print(p, vp=viewport(0, 0, width = unit(0.5, "npc"), just = c('left', 'bottom')))
print(p, vp=viewport(0.5, 0, angle = 90, height = unit(0.8, "npc"), width = 0.55, just = c('left', 'top')))

enter image description here

Axeman
  • 32,068
  • 8
  • 81
  • 94