ggformaEnglish

对齐实际绘图区

函数索引 / 拼图

align_forma()

按毫米测量并对齐 Base R、Lattice 和 ggplot2 的单个绘图区。

怎么用

输入原图。上下排列选 axis = 'x',左右并排选 axis = 'y'。slot 指定每个子图的宽和高。导出时采用同一图形设备,并为每张图留足空间。

返回结果

返回可用 +、| 和 / 组合的图块,以及对齐前后的边界坐标。

调用方式

align_forma(
  ...,
  plots = NULL,
  slot,
  axis = c("both", "x", "y"),
  device = NULL,
  insets = NULL,
  tolerance = 0.1
)

参数

...、plots、slot、axis、device、insets、tolerance

逐项参数说明(英文)

R 示例

p <- ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) + ggplot2::geom_point()
by_weight <- p + ggplot2::scale_y_continuous(labels = function(x) sprintf("%06.2f", x))
aligned <- align_forma(p, by_weight, slot = c(100, 75), axis = "x")
aligned$after
figure <- aligned$plots[[1]] / aligned$plots[[2]]
ggplot2::ggsave(tempfile(fileext = ".pdf"), figure, device = grDevices::pdf,
                width = 112, height = 162, units = "mm")

查看完整英文文档