Skip to content

Commit 409390a

Browse files
author
Yunuuuu
committed
feat: add ggplot method for ggalign_area
1 parent b1d20a0 commit 409390a

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ S3method(ggoncoplot,"NULL")
114114
S3method(ggoncoplot,default)
115115
S3method(ggoncoplot,formula)
116116
S3method(ggoncoplot,functon)
117+
S3method(ggplot,ggalign_area)
117118
S3method(ggplot_add,FacetSector)
118119
S3method(ggplot_build,ggalign_facet_sector_plot)
119120
S3method(ggplot_build,ggalign_heatmap)
@@ -553,5 +554,4 @@ importFrom(utils,getFromNamespace)
553554
importFrom(utils,getS3method)
554555
importFrom(utils,modifyList)
555556
importFrom(utils,packageName)
556-
importFrom(utils,packageVersion)
557557
importFrom(utils,str)

R/alignpatch-area.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,16 @@ as_areas.character <- function(x) {
192192
as_areas.patch_area <- function(x) new_areas(unclass(x))
193193

194194
#' @importFrom grid unit
195-
#' @importFrom ggplot2 aes margin theme ggplot
196-
#' @importFrom utils packageVersion
195+
#' @importFrom ggplot2 ggplot aes margin theme
196+
#' @keywords internal
197197
#' @export
198-
plot.ggalign_area <- function(x, ...) {
199-
data <- vec_data(x)
198+
ggplot.ggalign_area <- function(data, ...) {
199+
data <- vec_data(data)
200200
data$l <- data$l - 0.45
201201
data$r <- data$r + 0.45
202202
data$t <- data$t - 0.45
203203
data$b <- data$b + 0.45
204-
data$name <- as.factor(vec_seq_along(x))
204+
data$name <- as.factor(vec_seq_along(data))
205205
b_fun <- function(lim) {
206206
if (lim[1] < lim[2]) {
207207
lim <- seq(floor(lim[1]), ceiling(lim[2]), by = 1)
@@ -210,7 +210,7 @@ plot.ggalign_area <- function(x, ...) {
210210
}
211211
lim[-c(1, length(lim))]
212212
}
213-
ggplot(data) +
213+
ggplot(data, ...) +
214214
ggplot2::geom_rect(
215215
aes(
216216
xmin = .data$l, xmax = .data$r,
@@ -234,3 +234,6 @@ plot.ggalign_area <- function(x, ...) {
234234
plot.margin = margin(10, 10, 10, 10)
235235
)
236236
}
237+
238+
#' @export
239+
plot.ggalign_area <- function(x, ...) plot(ggplot(data = x, ...))

0 commit comments

Comments
 (0)