2

I need to put 2 columns of plots side by side (only one row in the example) and I can't manage to control the size of the plots and the position of the labels so that both plots are exactly aligned. This is the code the have now:

split.screen(c(1,2))
screen(1)
par(oma=c(0,1,0,0), mai=c(0.6,0.36,0.5,0.7), cex=0.5, mgp = c(0.5,0.1, 0), tck = -0.05) 
plot(datos$UN.CJF*1000, datos$Methane.Produced.CJF, pch = 16, cex = 0.5, col ="black", 
     xlab = "UN (g/d)", ylab = expression('CH'[4]*'(g/d)')) 

title(main = "a)", cex=0.8, line=0.5, adj=0, cex.lab=1.2)

datos$LWchangeD.CJF <- datos$LWchange.CJF/15

screen(2)
par(oma=c(0,1,0,0), mai=c(0.6,0.36,0.5,0.7), cex=0.5, mgp = c(0.5,0.1, 0), tck = -0.05)  
scatter2D(datos$UN.CJF*1000, datos$Methane.Produced.CJF,
          pch = 16,
          xlab = "UN (g/d)", ylab = "",
          colvar = datos$LWchangeD.CJF, clab = c("Liveweight change (kg/d)")
)
title(main = "b)", cex=0.8, line=-0.7, adj=0, cex.lab=1.2)

Notice how the size of the 2 figs is different

There must be a better way to do it. Any help would be MUCH appreciated

Alvaro

Alvaro
  • 21
  • 2
  • http://stackoverflow.com/questions/33181143/printing-ggplot-figures-side-by-side-in-r-markdown-html-file/33181252#33181252 – Bg1850 Nov 15 '15 at 23:04
  • @Bg1850: Seems unlikely that `grid.arrange` will do much useful with base `graphics::plot` output. They are rather different plotting paradigms. – IRTFM Nov 15 '15 at 23:51
  • @Alvaro. Size of what exactly? And do edit to include a library call for all non-default packages. (I'd say the x-axis it the major difference.) – IRTFM Nov 15 '15 at 23:59
  • Further to Bg1850, here is a way to use grid.arrange and base R plots: http://stackoverflow.com/questions/33612468/r-print-multiple-types-of-plots-on-one-page/33641108#33641108 – lawyeR Nov 16 '15 at 00:46

1 Answers1

0

grid.arrange did the trick, but I first re-did all my plots in ggplot2.

Thanks a lot for your suggestions

Alvaro

Alvaro
  • 21
  • 2