R/loon2ggplot-l_compound.R

Defines functions loon2ggplot.l_compound

Documented in loon2ggplot.l_compound

#' @rdname loon2ggplot
#' @import patchwork
#' @export
loon2ggplot.l_compound <- function(target, asAes = TRUE, selectedOnTop = TRUE,
                                   showNearestColor = FALSE, ...) {

  # locations <- g_getLocations(target)
  #
  # GGally::ggmatrix(plots = g_getPlots(target, asAes = asAes,
  #                                     selectedOnTop = selectedOnTop,
  #                                     showNearestColor = showNearestColor),
  #                  nrow = locations$nrow,
  #                  ncol = locations$ncol,
  #                  byrow = FALSE)

  locations <- loon::l_getLocations(target)
  layout_matrix <- locations$layout_matrix
  plots <- lapply(target,
                  function(x) {
                    loon2ggplot(x, asAes = asAes, selectedOnTop = selectedOnTop,
                                showNearestColor = showNearestColor, ...)
                  })

  positions <- layout_matrix2positions(layout_matrix, n = length(plots))

  plots$design <- do.call(c,
                          lapply(seq(nrow(positions)),
                                 function(i) {
                                   do.call(patchwork::area,
                                           positions[i, ])
                                 }))
  plots$heights <- locations$heights
  plots$widths <- locations$widths
  ggCompound(plots)
}

Try the loon.ggplot package in your browser

Any scripts or data that you put into this service are public.

loon.ggplot documentation built on Nov. 13, 2022, 1:06 a.m.