R/geom_crossbar_interactive.R, R/geom_errorbar_interactive.R, R/geom_linerange_interactive.R, and 1 more
geom_crossbar_interactive.RdThese geometries are based on ggplot2::geom_crossbar(), ggplot2::geom_errorbar(),
ggplot2::geom_linerange() and ggplot2::geom_pointrange().
See the documentation for those functions for more details.
geom_crossbar_interactive(...)
geom_errorbar_interactive(...)
geom_linerange_interactive(...)
geom_pointrange_interactive(...)arguments passed to base function, plus any of the interactive_parameters.
The interactive parameters can be supplied with two ways:
As aesthetics with the mapping argument (via ggplot2::aes()).
In this way they can be mapped to data columns and apply to a set of geometries.
As plain arguments into the geom_*_interactive function. In this way they can be set to a scalar value.
# add interactive intervals -------
library(ggplot2)
library(ggiraph)
# Create a simple example dataset
df <- data.frame(
trt = factor(c(1, 1, 2, 2)),
resp = c(1, 5, 3, 4),
group = factor(c(1, 2, 1, 2)),
upper = c(1.1, 5.3, 3.3, 4.2),
lower = c(0.8, 4.6, 2.4, 3.6)
)
p <- ggplot(df, aes(trt, resp, colour = group))
g <- p + geom_linerange_interactive(aes(ymin = lower, ymax = upper, tooltip = group))
x <- girafe(ggobj = g)
if( interactive() ) print(x)
g <- p + geom_pointrange_interactive(aes(ymin = lower, ymax = upper, tooltip = group))
x <- girafe(ggobj = g)
#> Error in (function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, fatten = deprecated(), lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) { layer(mapping = mapping, data = data, geom = "pointrange", stat = stat, position = position, show.legend = show.legend, inherit.aes = inherit.aes, params = list2(na.rm = na.rm, orientation = orientation, fatten = fatten, lineend = lineend, ...))})(structure(list(ymin = ~lower, ymax = ~upper), class = c("ggplot2::mapping", "uneval", "gg", "S7_object"), S7_class = structure(function (x = list(), ..., env = globalenv()) { warn_dots_empty() check_object(x, is.list, "a {.cls list}") x <- lapply(x, new_aesthetic, env = env) x <- S7::new_object(x) class(x) <- union(c("ggplot2::mapping", "uneval"), class(x)) x}, name = "mapping", parent = structure(list(class = "gg", constructor = function (.data) { stop(sprintf("S3 class <%s> doesn't have a constructor", class[[1]]), call. = FALSE)}, validator = NULL), class = "S7_S3_class"), package = "ggplot2", properties = list(), abstract = FALSE, constructor = function (x = list(), ..., env = globalenv()) { warn_dots_empty() check_object(x, is.list, "a {.cls list}") x <- lapply(x, new_aesthetic, env = env) x <- S7::new_object(x) class(x) <- union(c("ggplot2::mapping", "uneval"), class(x)) x}, class = c("S7_class", "S7_object")))): Problem while converting geom to grob.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `draw_panel()`:
#> ! unused argument (lineend = "butt")
if( interactive() ) print(x)
g <- p + geom_crossbar_interactive(aes(ymin = lower, ymax = upper, tooltip = group), width = 0.2)
x <- girafe(ggobj = g)
#> Error in (function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., middle.colour = NULL, middle.color = NULL, middle.linetype = NULL, middle.linewidth = NULL, box.colour = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, fatten = deprecated(), na.rm = FALSE, orientation = NA, show.legend = NA, inherit.aes = TRUE) { middle_gp <- list(colour = middle.color %||% middle.colour, linetype = middle.linetype, linewidth = middle.linewidth) box_gp <- list(colour = box.color %||% box.colour, linetype = box.linetype, linewidth = box.linewidth) layer(data = data, mapping = mapping, stat = stat, geom = GeomCrossbar, position = position, show.legend = show.legend, inherit.aes = inherit.aes, params = list2(middle_gp = middle_gp, box_gp = box_gp, fatten = fatten, na.rm = na.rm, orientation = orientation, ...))})(structure(list(ymin = ~lower, ymax = ~upper), class = c("ggplot2::mapping", "uneval", "gg", "S7_object"), S7_class = structure(function (x = list(), ..., env = globalenv()) { warn_dots_empty() check_object(x, is.list, "a {.cls list}") x <- lapply(x, new_aesthetic, env = env) x <- S7::new_object(x) class(x) <- union(c("ggplot2::mapping", "uneval"), class(x)) x}, name = "mapping", parent = structure(list(class = "gg", constructor = function (.data) { stop(sprintf("S3 class <%s> doesn't have a constructor", class[[1]]), call. = FALSE)}, validator = NULL), class = "S7_S3_class"), package = "ggplot2", properties = list(), abstract = FALSE, constructor = function (x = list(), ..., env = globalenv()) { warn_dots_empty() check_object(x, is.list, "a {.cls list}") x <- lapply(x, new_aesthetic, env = env) x <- S7::new_object(x) class(x) <- union(c("ggplot2::mapping", "uneval"), class(x)) x}, class = c("S7_class", "S7_object"))), width = 0.2): Problem while converting geom to grob.
#> ℹ Error occurred in the 1st layer.
#> Caused by error in `draw_panel()`:
#> ! unused arguments (middle_gp = list(NULL, NULL, NULL), box_gp = list(NULL, NULL, NULL))
if( interactive() ) print(x)
g <- p + geom_errorbar_interactive(aes(ymin = lower, ymax = upper, tooltip = group), width = 0.2)
x <- girafe(ggobj = g)
if( interactive() ) print(x)