大家好,我是R新手,最近在用xyplot和ggplot2做scatterplot. 我用两种方法做了同样的scatterplot,同样设定了margin,为什么出来的图大小不一样呢?
这是想要的size:
top.margin <- 1.44
bottom.margin <- 0.83
left.margin <- 1.3
right.margin <- 1.32
paper.width <- 11.7
paper.height <- 8.3
1. xyplot 用lattice制定margin:
lr.margin <- list(left.padding = list(x = left.margin, units = "inches"))
lr.margin$right.padding <- list(x = right.margin, units = "inches")
tb.margin <- list(bottom.padding = list(x = bottom.margin, units = "inches"))
tb.margin$top.padding <- list(x = top.margin, units = "inches")
lattice.options = list(layout.widths = lr.margin, layout.heights = tb.margin)
2. ggplot2 用plot.margin指定margin:
plot.margin=unit(x=c(top.margin,right.margin,bottom.margin,left.margin),units="inches")
为什么出来的结果不一样呢???关于R plot margin,我看过一个presentation介绍包括plot area, figure margin area 和outer margin area. 到底怎样把title和plot area一起算进figure margin area呢,凌乱了。。。