Skip to content

Commit

Permalink
Align: new method to add schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Dec 11, 2024
1 parent 285fe63 commit 05a94c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion R/align-.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Align <- ggproto("Align", AlignProto,
object_name
)
},
build = function(self, plot, direction, position, schemes,
build = function(self, plot, direction, position,
coords, extra_coords, previous_coords = NULL) {
panel <- .subset2(coords, "panel")
index <- .subset2(coords, "index")
Expand Down Expand Up @@ -333,6 +333,8 @@ Align <- ggproto("Align", AlignProto,
)
},

add_schemes = function(plot, schemes) plot_add_schemes(plot, schemes),

# Most parameters for the `Align` are taken automatically from `compute()`,
# `layout()` and `draw()`. However, some additional parameters may be
# removed in `setup_params`. You should put these paramters here, otherwise,
Expand Down
5 changes: 2 additions & 3 deletions R/plot-align-.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,15 @@ plot_build.ggalign_align_plot <- function(plot, ..., direction, schemes) {
ans <- align$build(
plot = plot@plot,
...,
direction = direction,
schemes = schemes
direction = direction
)

# remove axis titles, text, ticks used for alignment
if (isTRUE(plot@no_axes)) {
schemes$scheme_theme <- .subset2(schemes, "scheme_theme") +
theme_no_axes(switch_direction(direction, "y", "x"))
}
plot_add_schemes(ans, schemes)
align$add_schemes(ans, schemes)
}

ggproto_formals <- function(x) formals(environment(x)$f)
Expand Down

0 comments on commit 05a94c8

Please sign in to comment.