Skip to contents

Adding clickable links to data points on ggplot object

Usage

jmv_plotly_linked(p)

Arguments

p

ggplot object, with URL mapped to customdata inside aes()

Value

Interactive plot, output by ggplotly(), with clickable data points that open associated URLs

Examples

p <- mtcars |>
    tibble::rownames_to_column(var="vehicle") |>
    dplyr::mutate(link = paste0("https://www.google.com/search?q=", vehicle)) |>
    ggplot2::ggplot(ggplot2::aes(mpg, hp, customdata=link)) + ggplot2::geom_point()
jmv_plotly_linked(p)