0

I'm trying to create a ggiraph animated graph which uses the color of a point as the color of the border of a tooltip.

The example here https://davidgohel.github.io/ggiraph/articles/offcran/examples.html shows using the Use_fill argument to change the color of the background of the tooltip to match the color of the point, and suggests that to change the border you just need to use the Use_stroke argument. However, I must be missing something, because it doesn't appear to be working.

library(ggplot2)
library(ggiraph)

#get data set
dataset <- mtcars
dataset$carname <- row.names(dataset)
gg_scatter <- ggplot(dataset, 
                     aes(x = disp, y = qsec, tooltip = carname, 
                         data_id = carname, color= wt) ) + 
  geom_point_interactive(size=3) + 
  labs(title = "mouse over points") + 
  theme_minimal() + theme(
    plot.background = element_blank(),
    panel.background = element_blank()
  )


#using use_fill works fine at getting the tooltip to be colored with the same color as the plot.
girafe(ggobj = gg_scatter, 
       options = list(opts_tooltip(use_fill = TRUE),
                      opts_sizing(width = .7) ) )


#using use_stroke just results in the default colors.
girafe(ggobj = gg_scatter, 
       options = list(opts_tooltip(use_stroke = TRUE),
                      opts_sizing(width = .7) ) )`enter code here`
Tom H
  • 3
  • 2

0 Answers0