plotly.R
plotly.R copied to clipboard
Add interactivity for geom_pcp
It would be elegant to be able to create interactive parallel coordinate plots with plotly layered on the ggpcp library. Users should be able to select a line (or lines) and the entire line would highlight.
library(ggplot2)
data(mtcars)
mtcars_pcp <- mtcars |>
dplyr::mutate(
cyl = factor(cyl),
vs = factor(vs),
am = factor(am),
gear = factor(gear),
carb = factor(carb)
) |>
pcp_select(1:11) |> # select everything
pcp_scale() |>
pcp_arrange()
base <- mtcars_pcp |> ggplot(aes_pcp())
# Just the base plot:
base + geom_pcp()
# Ideally this would allow lines to be selected
ggplotly()
# Or something like:
highlight_key(mtcars) |> ... (ggplot2 code) |> ggplotly()