library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.2
library(ggiraph)
## Warning: package 'ggiraph' was built under R version 4.4.2
gg_obj <- ggplot(data = iris,
aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_line_interactive(aes(tooltip = Species,
data_id = Species),
linewidth = 2)
girafe(ggobj = gg_obj)
You can also embed plots, for example:
library(htmlwidgets)
## Warning: package 'htmlwidgets' was built under R version 4.4.2
gg_save <- girafe(ggobj = gg_obj)
saveWidget(gg_save, "graphique_interactif.html")
browseURL("graphique_interactif.html")
knitr::opts_chunk$set(echo = TRUE)
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.