Hi,

I am a novice of R and I have attended the coursea courses for computing
for R analysis.
Recently I am using both the lattice and ggplots package to create
scatterplot in R.
when using lattice package, I can contrl the whole graph size(including
plot area and title/footnote) with below codes:

xyplot(
  test2 ~ test1,
  data     = in.data,
  groups   = SEX,
  #title
  main     = textGrob(c("This is the title", "\nThis is the sub-title"),
                      x = unit(c(left.margin,left.margin), "inches"),
                      just  = "left",
                      gp    = gpar(fontsize = c(title.font, title.font),
lineheight = 1.5)),
  #footnote
  sub = textGrob(paste(footnote1,Sys.time(),sep="\n"),
                 x = unit(c(left.margin), "inches"),
                 y = unit(c(bottom.margin), "inches"),
                 just = c("left", "bottom"),
                 gp = gpar(fontsize = footer.font,lineheight=0.9))
# Figure margins
lattice.options = list(layout.widths = leftright.margin, layout.heights =
topbottome.margin)
)
You can see that the lattice.options can control the whole figure size
including title and footnote.
while with ggplot2, I create a plot use qplot(...) then control plot margin
with:
theme(plot.margin=unit(x=c(top.margin,right.margin,bottom.margin,left.margin),units="inches"))
then  add title and footnote with arrangeGrob.
 g<-arrangeGrob(myplot, main=textGrob(c(title1, title2),
                                       x = unit(c(left.margin,left.margin),
"inches"),
                                       y = unit(c(-top.margin,-top.margin),
"inches"),
                                       just  = "left",
                                       gp    = gpar(fontsize =
c(title.font, title.font),

fontface=c("plain","plain"),
                                                    lineheight = 1.5)),
                 sub = textGrob(paste(footnote1,Sys.time(),sep="\n"),
                                x = unit(c(left.margin), "inches"),
                                y = unit(c(bottom.margin), "inches"),
                                just = c("left", "bottom"),
                                gp = gpar(fontsize =
footer.font,lineheight=0.9)))

  g

In this way, the plot.margin only control the plot area, not control title
and footnote. So how should I do to control the both plot area and title
area in ggplot2 (just like lattice package)?
If the answer is not, in this case I will prefer lattice pakcage.

I will very appreciate your reply! Thanks!


Best regards,
Mina

	[[alternative HTML version deleted]]

