ggiraph

Make ggplot Graphics Interactive

The ggiraph package let R users make ggplot interactive. The package is an htmlwidget.

Documentation

library(ggplot2)
library(ggiraph)
theme_set(theme_minimal())

# geom_point_interactive example
gg_point_1 <- ggplot(mtcars, aes(x = disp, y = qsec, 
        color = wt, tooltip = row.names(mtcars), data_id = row.names(mtcars) ) ) + 
    geom_point_interactive(size=2) + 
  scale_color_gradient(low = "#F3C899", high = "#8C120A") 

# htmlwidget call
x <- girafe(ggobj = gg_point_1, width_svg = 5, height_svg = 4, width = .75)
x <- girafe_options(x = x,
    opts_tooltip(opacity = .8, css = "background-color:gray;color:white;padding:2px;border-radius:2px;"),
    opts_hover(css = "fill:#1279BF;stroke:#1279BF;cursor:pointer;") )
x