Changer vos ggplot en graphiques web dynamiques

Le package permet la production de graphiques ‘ggplot2’ interactifs. Il est à utiliser dans les documents R Markdown et s’adapte particulièrement bien aux applications Shiny en permettant la sélection des points et formes sous forme de valeurs réactives.

Documentation officielle

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)
x <- girafe_options(x = x, opts_sizing(width = .75), 
    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