Skip to content

Commit

Permalink
Merge pull request #177 from teunbrand/guide_methods
Browse files Browse the repository at this point in the history
Guide methods
  • Loading branch information
eliocamp committed Nov 9, 2023
2 parents 73b187f + 2e48f72 commit cc3946b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Expand Up @@ -3,6 +3,9 @@
S3method(autoplot,eof)
S3method(cut,eof)
S3method(guide_gengrob,colorstrip)
S3method(guide_gengrob,vector)
S3method(guide_geom,colorstrip)
S3method(guide_geom,vector)
S3method(guide_train,colorstrip)
S3method(guide_train,vector)
S3method(interleave,default)
Expand Down Expand Up @@ -162,6 +165,7 @@ importFrom(data.table,"%chin%")
importFrom(ggplot2,.pt)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,guide_gengrob)
importFrom(ggplot2,guide_geom)
importFrom(ggplot2,guide_train)
importFrom(ggplot2,scale_type)
importFrom(grid,makeContent)
Expand Down
13 changes: 13 additions & 0 deletions R/guide_colorstrip.R
Expand Up @@ -171,6 +171,19 @@ guide_train.colorstrip <- function(guide, scale, aesthetic = NULL) {
guide
}

#' @usage NULL
#' @format NULL
#' @export
#' @rdname guide_colourstrip
#' @keywords internal
#' @importFrom ggplot2 guide_geom
guide_geom.colorstrip <- function(guide, layers, ...) {
if (!inherits(ggplot2::guide_none(), "Guide")) {
return(NextMethod())
}
bar <- ggplot2::guide_colourbar()
bar$get_layer_key(guide, layers)
}

#' @export
#' @rdname guide_colourstrip
Expand Down
19 changes: 19 additions & 0 deletions R/guide_vector.R
Expand Up @@ -111,6 +111,25 @@ guide_train.vector <- function(guide, scale, aesthetic = NULL) {
guide
}

#' @export
#' @importFrom ggplot2 guide_geom
guide_geom.vector <- function(guide, layers, ...) {
if (!inherits(ggplot2::guide_none(), "Guide")) {
return(NextMethod())
}
legend <- ggplot2::guide_legend()
legend$get_layer_key(guide, layers)
}

#' @export
#' @importFrom ggplot2 guide_gengrob
guide_gengrob.vector <- function(guide, theme) {
if (!inherits(ggplot2::guide_none(), "Guide")) {
return(NextMethod())
}
legend <- ggplot2::guide_legend()
legend$draw(theme, guide)
}


globalVariables(c("C", "R", "key.row", "key.col", "label.row", "label.col"))
Expand Down

0 comments on commit cc3946b

Please sign in to comment.