# NOT RUN {
library(ggplot2)
library(ggiraph)
gg_jitter <- ggplot(
mpg, aes(cyl, hwy, group = cyl)) +
geom_boxplot() +
facet_wrap(~manufacturer,
labeller = labeller_interactive(id_label)) +
theme(strip.text = element_text_interactive())
x <- girafe(ggobj = gg_jitter)
if(interactive()) print(x)
lab_custom <- function(z, prefix = "label: ") {
label_interactive(label = z, data_id = z, tooltip = paste0(prefix, z))
}
gg_jitter <- ggplot(diamonds, aes(x = x)) +
geom_density() +
facet_grid(color ~ cut,
labeller = labeller(
cut = labeller_interactive(lab_custom, prefix = "cut: "),
color = labeller_interactive(lab_custom, prefix = "color: ")
)) +
theme_light() +
theme(
strip.text.x = element_text_interactive(),
strip.text.y = element_text_interactive()
)
x <- girafe(ggobj = gg_jitter, width_svg = 8, height_svg = 5)
if (interactive()) print(x)
# }
Run the code above in your browser using DataLab