Commit 9b8c5d5b authored by houyun's avatar houyun
Browse files

fix a few bugs

parent bf357ff3
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -100,9 +100,9 @@ ggplot_add.geom_ggplot <- function(object, plot, object_name) {
    class(plot) <- c("gggplot", class(plot))
  }

  gglist <- lapply(gglist, ggplotGrob)
  params <- c(list(mapping = mapping,
                   marker = marker(grob = gglist),
                   data = data,
                   marker = marker(grob = lapply(gglist, ggplotGrob)),
                   show.legend = FALSE,
                   width_unit = object$width_unit,
                   height_unit = object$height_unit,
@@ -119,6 +119,7 @@ ggplot_build.gggplot <- function(plot) {
  gdefs <- attr(plot, "guides")
  if (is.null(gdefs) || length(gdefs) < 1) {
    plot <- NextMethod()
    plot <- ggplot2::ggplot_gtable(plot)
  } else {
    plot <- .rebuild_guides(plot)
  }
@@ -128,6 +129,7 @@ ggplot_build.gggplot <- function(plot) {
#' @export
print.gggplot <- function(x, ...) {
  x <- ggplot_build(x)
  grid::grid.newpage()
  grid.draw(x)
}

@@ -142,6 +144,9 @@ plot.gggplot <- print.gggplot
#' @noRd
.get_guides <- function(gg) {
  if (!inherits(gg, "gtable")) {
    if (inherits(gg, "gggplot")) {
      class(gg) <- setdiff(class(gg), "gggplot")
    }
    gg <- ggplot2::ggplotGrob(gg)
  }

+3 −3
Original line number Diff line number Diff line
@@ -124,9 +124,9 @@ Geomshaping <- ggproto(
    }

    data <- coord$transform(data, panel_params)
    if (!tibble::is_tibble(data)) {
      data <- as_tibble(data)
    }
    # if (!tibble::is_tibble(data)) {
    #   data <- as_tibble(data)
    # }
    n <- nrow(data)
    if (!is.null(shaping)) {
      if (!inherits(shaping, "marker")) {
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ marker <- function(grob = "square",
  grob_is_na <- vapply(grob, function(.grob) {
    if (is.atomic(.grob) && is.na(.grob)) TRUE else FALSE
  }, logical(1))
  grob <- rep_len(grob, ll)
  grob <- rename_grob(rep_len(grob, ll))
  label <- rep_len(grob, ll)
  width <- rep_len(width, ll)
  height <- rep_len(height, ll)