Skip to content

Instantly share code, notes, and snippets.

@charliejhadley
Created January 5, 2026 10:31
Show Gist options
  • Select an option

  • Save charliejhadley/3aefbd70544d5c98d7a56cf9a877474b to your computer and use it in GitHub Desktop.

Select an option

Save charliejhadley/3aefbd70544d5c98d7a56cf9a877474b to your computer and use it in GitHub Desktop.
ggiraph-legend.R
library(tidyverse)
library(ggiraph)
library(fivethirtyeight)
p_bechdel <- ggplot(bechdel) +
aes(x = budget_2013,
y = domgross_2013,
data_id = clean_test,
colour = clean_test) +
geom_point_interactive(aes(`data-id` = clean_test), extra_interactive_params = "data-id") +
scale_color_discrete_interactive(extra_interactive_params = "data-id",
`data-id` = unique(bechdel$clean_test),
palette = 'Set1',
data_id = function(breaks) as.character(breaks))
girafe(ggobj = p_bechdel,
options = list(opts_hover(girafe_css("stroke:black;fill:black;")),
opts_hover_key(girafe_css("stroke:black;fill:black"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment