Transform a ggplot2/plot2 object to an interactive plot using the Plotly R Open Source Graphing Library.
Examples
if (requireNamespace("plotly", quietly = TRUE)) {
mtcars |>
plot2(mpg, hp) |>
as_plotly()
}
#> Using type = "point" since both axes are numeric
if (requireNamespace("plotly", quietly = TRUE)) {
mtcars |>
plot2(mpg, hp) |>
as_plotly(dragmode = "pan") |>
plotly_style(marker.line.color = "red",
hoverinfo = "y")
}
#> Using type = "point" since both axes are numeric