Experiment
annotate
## function (geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
## ymin = NULL, ymax = NULL, xend = NULL, yend = NULL, ...,
## na.rm = FALSE)
## {
## if (is_string(geom, c("abline", "hline", "vline"))) {
## cli::cli_warn(c("{.arg geom} must not be {.val {geom}}.",
## i = "Please use {.fn {paste0('geom_', geom)}} directly instead."))
## }
## position <- compact(list(x = x, xmin = xmin, xmax = xmax,
## xend = xend, y = y, ymin = ymin, ymax = ymax, yend = yend))
## aesthetics <- c(position, list(...))
## lengths <- lengths(aesthetics)
## n <- unique0(lengths)
## if (length(n) > 1L) {
## n <- setdiff(n, 1L)
## }
## if (length(n) > 1L) {
## bad <- lengths != 1L
## details <- paste0(names(aesthetics)[bad], " (", lengths[bad],
## ")")
## cli::cli_abort("Unequal parameter lengths: {details}")
## }
## data <- data_frame0(!!!position, .size = n)
## params <- list2(na.rm = na.rm, ...)
## reject <- intersect(names(params), c("position", "stat"))
## if (length(reject) > 0) {
## cli::cli_warn("{.fn annotate} can't accept {.or {.arg {reject}}} argument{?s}.")
## params <- params[setdiff(names(params), reject)]
## }
## layer(geom = geom, params = params, stat = StatIdentity,
## position = PositionIdentity, data = data, mapping = aes_all(names(data)),
## inherit.aes = FALSE, show.legend = FALSE)
## }
## <bytecode: 0x7fec407770e8>
## <environment: namespace:ggplot2>
compute_group_stampI <- function(data, scales){
data.frame(x = I(.5), y = I(.5),
xend = I(.75), yend = I(.75),
xmin = I(.25), ymin = I(.25),
xmax = I(.75), ymax = I(.75))
# width = I(.5), height = I(.5))
}
StatStampI <- ggproto("StatStampI", Stat,
compute_group = compute_group_stampI)
library(statexpress)
ggplot(data = data.frame(x = NA)) +
qlayer(stat = StatStampI, geom = GeomPoint) +
qlayer(stat = StatStampI, geom = GeomSegment) +
qlayer(stat = StatStampI, geom = GeomRect, alpha = .2, fill = "green") +
qlayer(stat = StatStampI, geom = GeomPoint, x = I(.4), size = 8) +
qlayer(stat = StatStampI, geom = GeomTile, alpha = .1) +
coord_equal()

compute_group_stamp_numeric <- function(data, scales){
data.frame(x = 0, y = 0,
xend = 1, yend = 1,
xmin = -.5, ymin = -.5,
xmax = .5, ymax = .5)
# width = I(.5), height = I(.5))
}
StatStampNumeric <- ggproto("StatStampNumeric", Stat,
compute_group = compute_group_stampI)
library(statexpress)
ggplot(data = data.frame(x = NA)) +
ggchalkboard:::theme_glassboard() +
qlayer(stat = StatStampNumeric, geom = GeomPoint) +
qlayer(stat = StatStampNumeric, geom = GeomSegment) +
qlayer(stat = StatStampNumeric, geom = GeomRect, alpha = .2, fill = "green") +
qlayer(stat = StatStampNumeric, geom = GeomPoint, x = .4, size = 8) +
qlayer(stat = StatStampNumeric, geom = GeomTile, alpha = .3, color = "pink")
