library(ggplot2)
library(ggiraph)
dat <- mtcars
dat$id <- "id"
dat$label <- "a line"
dat <- dat[order(dat$wt), ]
p <- ggplot(
data = dat,
mapping = aes(
x = wt, y = mpg, data_id = id, tooltip = label)) +
geom_line_interactive(color = "white", size = .75,
hover_nearest = TRUE) +
theme_dark() +
theme(plot.background = element_rect(fill="black"),
panel.background = element_rect(fill="black"),
text = element_text(colour = "white"),
axis.text = element_text(colour = "white")
)
x <- girafe(
ggobj = p,
options = list(
opts_hover(
css = girafe_css_bicolor(
primary = "yellow", secondary = "black"))
))
if (interactive()) print(x)
Run the code above in your browser using DataLab