geom_annotation_func.Rd
geom_annotation
Set of aesthetic mappings created by aes()
. If specified and
inherit.aes = TRUE
(the default), it is combined with the default mapping
at the top level of the plot. You must supply mapping
if there is no plot
mapping.
A tibble with the column of grob
function to plot, p <- plot.fun(data, ...)
other parameters to plot.fun
A numeric vector or unit object specifying x-location.
A numeric vector or unit object specifying y-location.
A numeric vector or unit object specifying width.
A numeric vector or unit object specifying height.
A string or numeric
vector specifying the justification of the viewport
relative to its (x, y) location. If there are two values, the first
value specifies horizontal justification and the second value specifies
vertical justification. Possible string values are: "left"
,
"right"
, "centre"
, "center"
, "bottom"
,
and "top"
. For numeric values, 0 means left alignment
and 1 means right alignment.
## prepare data
library(gg.layers)
library(ggplot2)
library(rcolors)
data("d_trendPerc")
d_mask <- mutate(d_trendPerc, mask = perc <= 0.99) %>% as_tibble()
n <- nrow(d_mask) * 2
dat <- rbind(cbind(type = "a", d_mask), cbind(type = "b", d_mask)) %>%
mutate(val = rnorm(n))
brks <- seq(0.9, 1, 0.025)
nbrk <- length(brks) - 1
cols <- get_color(rcolors$amwg256, nbrk)
## option1
# the part of not significant
ggplot(data = dat, aes(x, y)) +
geom_raster(aes(fill = perc)) +
layer_barchart(aes(z = val),
width = unit(0.3, "npc"),
height = unit(0.3, "npc"),
brks = brks, cols = cols
) +
facet_wrap(~type)
## option2
func <- function(data, ...) {
add_barchart(data$z, brks, cols, ...)
}
ggplot(data = dat, aes(x, y)) +
geom_raster(aes(fill = perc)) +
geom_annotation_func(aes(z = val), plot.fun = func) +
facet_wrap(~type)