Skip to contents

The layer is based on ggplot2::annotate(). See the documentation for that function for more details.

Usage

annotate_interactive(...)

Arguments

...

arguments passed to base function, plus any of the interactive_parameters.

Details for annotate_*_interactive functions

The interactive parameters can be supplied as arguments in the relevant function and they can be scalar values or vectors depending on params on base function.

Examples

# add interactive annotation to a ggplot -------
library(ggplot2)
library(ggiraph)
library(gdtools)
#> 
#> Attaching package: ‘gdtools’
#> The following object is masked from ‘package:ggiraph’:
#> 
#>     match_family

register_liberationsans()
#> [1] TRUE

gg <- ggplot(mtcars, aes(x = disp, y = qsec)) +
  geom_point(size = 2) +
  annotate_interactive(
    "rect",
    xmin = 100,
    xmax = 400,
    fill = "red",
    data_id = "an_id",
    tooltip = "a tooltip",
    ymin = 18,
    ymax = 20,
    alpha = .5
  ) +
  theme_minimal(base_family = "Liberation Sans", base_size = 11)

girafe(
  ggobj = gg,
  width_svg = 5,
  height_svg = 4,
  dependencies = list(
    liberationsansHtmlDependency()
  )
)